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 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-17',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-18 05:50:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 09:20:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 09:20:52', '104', '', '192.168.1.13', '', '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-18',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-18 05:50:56";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 05:51:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 09:21:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 09:21:05', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 05:51:08";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 09:21:08", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 09:21:08', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 05:51:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 09:21:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 09:21:17', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 05:53:03";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 09:23:03", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 09:23:03', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 06:41:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 10:11:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 10:11:46', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762785827d08
-- ----------------------------------------------------------------------------------------------------

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-18 09:23:04', '06762785827d08', '1', '0.00', '0', '0', '1', '520.00', '520', '520', '0', '1', '2024-12-18 10:11:46', '', '104', '0', 'نقدي', '1', '0', '3', '94', 'نقدي', '2' ,'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-18','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','اضافة فاتورة مبيعات','149973', '0', '2024-12-18 10:11:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '520', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 09:23:04','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', '149973', '5', '16374', '1', '300', '300', '0', '', '1', '2024-12-18 10:11:46', '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 = 547863;
 INSERT INTO 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-18', 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-18', 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 = '20', userid = '104', storedetaildate = '2024-12-18 10:11: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', '149973', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '104', '2024-12-18 10:11:46','0','0');
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', '149973', '5', '16377', '1', '220', '220', '0', '', '1', '2024-12-18 10:11:46', '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 = 547864;
 INSERT INTO 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-18', 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-18', 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 = '35', userid = '104', storedetaildate = '2024-12-18 10:11:46' WHERE storedetailid = '16376';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16377', '1', '1', '1', '149973', 'اضافة فاتورة مبيعات', 'sellbillController.php', '36', '35', '104', '2024-12-18 10:11:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '520',  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','520', '0', '1', 'اضافة فاتورة مبيعات', '149973', '520', '2024-12-18 10:11:46', '104',  '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-18', 520, 395, 395
                    , 401, 395, 401, 407.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,395, 408, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+395, sellCostMeanBuyPrice = sellCostMeanBuyPrice+401
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+401
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+407.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+395
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+408
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 520, 395, 395
                    , 401, 395, 401, 407.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,395, 408, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+395, sellCostMeanBuyPrice = sellCostMeanBuyPrice+401
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+401
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+407.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+395
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+408
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 395, 395
                    , 401, 395, 401, 407.5, 395, 408)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+520, netSellCostBuyPrice = netSellCostBuyPrice+395
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+395
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+401
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+395
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+401
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+407.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+395
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+408;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762785827d08 and sellbillId = 149973 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676283c545fda
-- ----------------------------------------------------------------------------------------------------

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-18 10:11:49', '0676283c545fda', '1', '0.00', '0', '0', '1', '210.00', '210', '210', '0', '1', '2024-12-18 10:12:09', '', '104', '0', 'نقدي', '1', '0', '3', '96', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','149974', '0', '2024-12-18 10:12:09', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '210', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 10:11:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36005;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149974', '5', '15855', '1', '210', '210', '0', '', '1', '2024-12-18 10:12:09', '15855', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36005-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 = 547865;
 INSERT INTO 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-18', 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-18', 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 = '28', userid = '104', storedetaildate = '2024-12-18 10:12:09' WHERE storedetailid = '15854';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15855', '1', '1', '1', '149974', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29', '28', '104', '2024-12-18 10:12:09','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '730',  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 ('520','210', '0', '1', 'اضافة فاتورة مبيعات', '149974', '730', '2024-12-18 10:12:09', '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-18', 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;
 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-18', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 210, 145, 145
                    , 145, 145, 145, 145, 145, 145)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+210, 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 0676283c545fda and sellbillId = 149974 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676283da15fb2
-- ----------------------------------------------------------------------------------------------------

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-18 10:12:10', '0676283da15fb2', '1', '0.00', '0', '0', '1', '270.00', '270', '270', '0', '1', '2024-12-18 10:20:21', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','270','0','','0','0','270','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','149975', '0', '2024-12-18 10:20:21', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '270', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 10:12:10','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', '149975', '14', '16450', '1', '270', '270', '0', '', '1', '2024-12-18 10:20:21', '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 = 547866;
 INSERT INTO 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-18', 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-18', 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 = '17', userid = '104', storedetaildate = '2024-12-18 10:20:21' WHERE storedetailid = '16449';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16450', '1', '1', '1', '149975', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '104', '2024-12-18 10:20:21','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '1000',  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 ('730','270', '0', '1', 'اضافة فاتورة مبيعات', '149975', '1000', '2024-12-18 10:20:21', '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-18', 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;
 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-18', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 270, 200, 200
                    , 200, 200, 200, 200, 200, 200)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+270, 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 0676283da15fb2 and sellbillId = 149975 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676283c339bfb
-- ----------------------------------------------------------------------------------------------------

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-18 10:11:47', '0676283c339bfb', '1', '0.00', '0', '0', '1', '310.00', '310', '310', '0', '1', '2024-12-18 10:24:00', '', '104', '0', 'نقدي', '1', '0', '3', '25', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','149976', '0', '2024-12-18 10:24:00', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '310', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 10:11:47','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', '149976', '5', '16321', '1', '310', '310', '0', '', '1', '2024-12-18 10:24:00', '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 = 547867;
 INSERT INTO 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-18', 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-18', 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 = '19', userid = '104', storedetaildate = '2024-12-18 10:24:00' WHERE storedetailid = '16320';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16321', '1', '1', '1', '149976', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '104', '2024-12-18 10:24:00','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '1310',  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 ('1000','310', '0', '1', 'اضافة فاتورة مبيعات', '149976', '1310', '2024-12-18 10:24:00', '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-18', 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-18', 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 0676283c339bfb and sellbillId = 149976 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676286a149eee
-- ----------------------------------------------------------------------------------------------------

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-18 10:24:01', '0676286a149eee', '1', '0.00', '0', '0', '1', '720.00', '720', '720', '0', '1', '2024-12-18 10:33:50', '', '104', '0', 'نقدي', '1', '0', '3', '93', 'نقدي', '4' ,'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-18','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','اضافة فاتورة مبيعات','149977', '0', '2024-12-18 10:33:50', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '720', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 10:24:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34667;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06908', '149977', '5', '15735', '1', '145', '145', '0', '', '1', '2024-12-18 10:33:50', '15735', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34667-1,','1','1','0','0','145','145','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 = 547868;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15735, '2024-12-18', 145, 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+145, 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-18', 145, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+145, 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 = '2', userid = '104', storedetaildate = '2024-12-18 10:33:50' WHERE storedetailid = '15734';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15735', '1', '1', '1', '149977', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '104', '2024-12-18 10:33:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34509;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06826', '149977', '5', '15509', '1', '220', '220', '0', '', '1', '2024-12-18 10:33:50', '15509', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34509-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
        , lastbuyprice_withTax = 235, meanbuyprice_withTax = 173, lastbuyprice_withDiscountAndTax = 235
                where sellbilldetailid = 547869;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15509, '2024-12-18', 220, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 235, 173, 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+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+173
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 220, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 173, 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+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+173
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 10:33:50' WHERE storedetailid = '15508';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15509', '1', '1', '1', '149977', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '104', '2024-12-18 10:33:50','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', '149977', '5', '14390', '1', '120', '120', '0', '', '1', '2024-12-18 10:33:50', '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 = 547870;
 INSERT INTO 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-18', 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-18', 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 = '1', userid = '104', storedetaildate = '2024-12-18 10:33:50' WHERE storedetailid = '14389';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14390', '1', '1', '1', '149977', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-18 10:33:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30100;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06034', '149977', '5', '13491', '1', '235', '235', '0', '', '1', '2024-12-18 10:33:50', '13491', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30100-1,','1','1','0','0','235','235','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 = 547871;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13491, '2024-12-18', 235, 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+235, 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-18', 235, 380, 380
                    , 380, 380, 380, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, 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 = '1', userid = '104', storedetaildate = '2024-12-18 10:33:50' WHERE storedetailid = '13490';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13491', '1', '1', '1', '149977', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-18 10:33:50','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2030',  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 ('1310','720', '0', '1', 'اضافة فاتورة مبيعات', '149977', '2030', '2024-12-18 10:33:50', '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-18', 720, 1000, 1000
                    , 1000, 1000, 1000, 1000
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 338, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+1000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1000
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , 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-18', 720, 1000, 1000
                    , 1000, 1000, 1000, 1000
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 338, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+1000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1000
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , 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, 720, 1000, 1000
                    , 1000, 1000, 1000, 1000, 400, 338)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+720, netSellCostBuyPrice = netSellCostBuyPrice+1000
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1000
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1000
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1000
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1000
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1000
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+400
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+338;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676286a149eee and sellbillId = 149977 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:03:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 10:33:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 10:33:51', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:10:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 10:40:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 10:40:36', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:15:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 10:45:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 10:45:48', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:15:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 10:45:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 10:45:55', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:16:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 10:46:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 10:46:05', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:16:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 10:46:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 10:46:18', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:28:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 10:58:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 10:58:42', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676285c616f3e
-- ----------------------------------------------------------------------------------------------------

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-18 10:20:22', '0676285c616f3e', '1', '0.00', '0', '0', '1', '630.00', '630', '630', '0', '1', '2024-12-18 10:58:42', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','630','0','','0','0','630','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','149978', '0', '2024-12-18 10:58:42', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '630', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 10:20:22','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35892;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07066', '149978', '5', '16069', '1', '280', '280', '0', '', '1', '2024-12-18 10:58:42', '16069', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35892-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 = 547872;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16069, '2024-12-18', 280, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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-18', 280, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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 = '31', userid = '104', storedetaildate = '2024-12-18 10:58:42' WHERE storedetailid = '16068';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16069', '1', '1', '1', '149978', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32', '31', '104', '2024-12-18 10:58:42','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', '149978', '1', '16077', '1', '350', '350', '0', '', '1', '2024-12-18 10:58:42', '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 = 547873;
 INSERT INTO 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-18', 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-18', 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 = '7', userid = '104', storedetaildate = '2024-12-18 10:58:42' WHERE storedetailid = '16076';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16077', '1', '1', '1', '149978', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '104', '2024-12-18 10:58:42','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2660',  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 ('2030','630', '0', '1', 'اضافة فاتورة مبيعات', '149978', '2660', '2024-12-18 10:58:42', '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-18', 630, 505, 505
                    , 505, 505, 505, 505
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,505, 505, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+630, sellCostBuyPrice =sellCostBuyPrice+505
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+505, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+505, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+505
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+505
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+505
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 630, 505, 505
                    , 505, 505, 505, 505
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,505, 505, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+630, sellCostBuyPrice =sellCostBuyPrice+505
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+505, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+505, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+505
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+505
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+505
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 630, 505, 505
                    , 505, 505, 505, 505, 505, 505)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+630, netSellCostBuyPrice = netSellCostBuyPrice+505
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+505
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+505
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+505
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+505
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+505
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+505
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+505;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676285c616f3e and sellbillId = 149978 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067628bda860d7
-- ----------------------------------------------------------------------------------------------------

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-18 10:46:18', '067628bda860d7', '1', '0.00', '0', '0', '1', '470.00', '470', '470', '0', '1', '2024-12-18 11:19:33', '', '104', '0', 'نقدي', '1', '0', '3', '94', 'نقدي', '2' ,'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-18','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','اضافة فاتورة مبيعات','149979', '0', '2024-12-18 11:19:33', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '470', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 10:46:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36095;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07255', '149979', '5', '16369', '1', '260', '260', '0', '', '1', '2024-12-18 11:19:33', '16369', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36095-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 = 547874;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16369, '2024-12-18', 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-18', 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 = '9', userid = '104', storedetaildate = '2024-12-18 11:19:33' WHERE storedetailid = '16368';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16369', '1', '1', '1', '149979', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-18 11:19:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36005;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149979', '5', '15855', '1', '210', '210', '0', '', '1', '2024-12-18 11:19:33', '15855', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36005-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 = 547875;
 INSERT INTO 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-18', 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-18', 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 = '27', userid = '104', storedetaildate = '2024-12-18 11:19:33' WHERE storedetailid = '15854';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15855', '1', '1', '1', '149979', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28', '27', '104', '2024-12-18 11:19:33','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '3130',  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 ('2660','470', '0', '1', 'اضافة فاتورة مبيعات', '149979', '3130', '2024-12-18 11:19:33', '104',  '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-18', 470, 355, 355
                    , 355, 355, 355, 355
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,355, 355, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+355
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+355, sellCostMeanBuyPrice = sellCostMeanBuyPrice+355
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+355, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+355
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+355
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+355
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+355
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 470, 355, 355
                    , 355, 355, 355, 355
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,355, 355, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+355
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+355, sellCostMeanBuyPrice = sellCostMeanBuyPrice+355
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+355, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+355
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+355
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+355
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+355
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 355, 355
                    , 355, 355, 355, 355, 355, 355)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+470, netSellCostBuyPrice = netSellCostBuyPrice+355
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+355
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+355
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+355
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+355
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+355
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+355
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+355;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067628bda860d7 and sellbillId = 149979 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:49:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:19:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:19:34', '104', 'addsellBill', '192.168.1.13', '', '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-18 07:52:33";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:22:33", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 11:22:33', '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-18 07:52:34";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:52:51";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:22:51", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:22:51', '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-18 07:52:55";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:22:55", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:22: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-18 07:58:24";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:28:24", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 11:28:24', '75', '', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:58:36";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:28:36", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 11:28:36', '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-18 07:58:39";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:28:39", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:28:39', '75', 'showDetail', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149673');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:58:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:28:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:28:51', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676293a68c476
-- ----------------------------------------------------------------------------------------------------

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-18 11:19:34', '0676293a68c476', '1', '0.00', '0', '0', '1', '360.00', '360', '360', '0', '1', '2024-12-18 11:28:51', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','149980', '0', '2024-12-18 11:28:51', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '360', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 11:19:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36145;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0A305', '149980', '6', '16387', '1', '360', '360', '0', '', '1', '2024-12-18 11:28:51', '16387', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36145-1,','1','1','0','0','360','360','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 = 547876;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16387, '2024-12-18', 360, 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+360, 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-18', 360, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, 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 = '104', storedetaildate = '2024-12-18 11:28:51' WHERE storedetailid = '16386';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16387', '1', '1', '1', '149980', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-18 11:28:51','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '3490',  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 ('3130','360', '0', '1', 'اضافة فاتورة مبيعات', '149980', '3490', '2024-12-18 11:28: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-18', 360, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, 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;
 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-18', 360, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 360, 300, 300
                    , 300, 300, 300, 300, 300, 300)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+360, 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 0676293a68c476 and sellbillId = 149980 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:58:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:28:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:28:52', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:59:33";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:29:33", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:29: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 06762946b782c2
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(149,@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-18 11:22:51', '06762946b782c2', '149', '1.00', '3739', '100', '1', '3838.00', '3738', '0', '3738', '1', '2024-12-18 11:29:33', '', '75', '0', 'دينا المسيري z110', '2', '1', '3', '98', 'دينا المسيري z110', '11' ,'0','','','','','-1','0','0','0','0','0','3738','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '3739', userid = '75' WHERE clientid = '149';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('149','1.00','3738','0','اضافة فاتورة مبيعات','149981', '3739', '2024-12-18 11:29:33', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3738', '0', null, '0', null, null,'', '0','1','1','3738','1','2024-12-18 11:22:51','0','0');
UPDATE client SET  inUse = 0 where clientid = 149;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35418;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149981', '14', '15853', '1', '280', '280', '0', '', '1', '2024-12-18 11:29:33', '15853', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35418-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 = 547877;
 INSERT INTO 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-18', 272.70453361126, 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+272.70453361126, 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-18', 272.70453361126, 220, 220
                    , 220, 220, 220, 220.79
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+272.70453361126, 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 = '22', userid = '75', storedetaildate = '2024-12-18 11:29:33' WHERE storedetailid = '15852';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15853', '1', '1', '1', '149981', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '75', '2024-12-18 11:29:33','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', '149981', '14', '16449', '1', '280', '280', '0', '', '1', '2024-12-18 11:29:33', '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 = 547878;
 INSERT INTO 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-18', 272.70453361126, 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+272.70453361126, 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-18', 272.70453361126, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+272.70453361126, 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 = '21', userid = '75', storedetaildate = '2024-12-18 11:29:33' WHERE storedetailid = '16448';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16449', '1', '1', '1', '149981', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '75', '2024-12-18 11:29:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36283;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3337', '149981', '1', '16411', '1', '600', '600', '0', '', '1', '2024-12-18 11:29:33', '16411', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36283-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 = 547879;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16411, '2024-12-18', 584.36685773841, 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+584.36685773841, 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-18', 584.36685773841, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 500, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+584.36685773841, 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 = '14', userid = '75', storedetaildate = '2024-12-18 11:29:33' WHERE storedetailid = '16410';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16411', '1', '1', '1', '149981', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-18 11:29:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36163;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3331', '149981', '1', '16398', '1', '160', '160', '0', '', '1', '2024-12-18 11:29:33', '16398', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36163-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 = 547880;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16398, '2024-12-18', 155.83116206357, 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+155.83116206357, 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-18', 155.83116206357, 110, 110
                    , 110, 110, 110, 110
                    , 0, 0, 0, 0
                    , 0, 0, 0, 110, 110, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155.83116206357, 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 = '12', userid = '75', storedetaildate = '2024-12-18 11:29:33' WHERE storedetailid = '16397';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16398', '1', '1', '1', '149981', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-18 11:29:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36092;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07272', '149981', '5', '16368', '1', '490', '490', '0', '', '1', '2024-12-18 11:29:34', '16368', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36092-1,','1','1','0','0','490','490','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 = 547881;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16368, '2024-12-18', 477.2329338197, 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+477.2329338197, 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-18', 477.2329338197, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+477.2329338197, 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 = '9', userid = '75', storedetaildate = '2024-12-18 11:29:34' WHERE storedetailid = '16367';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16368', '1', '1', '1', '149981', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-18 11:29: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', '149981', '5', '16434', '1', '200', '200', '0', '', '1', '2024-12-18 11:29: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 = 547882;
 INSERT INTO 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-18', 194.78895257947, 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+194.78895257947, 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-18', 194.78895257947, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+194.78895257947, 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 = '10', userid = '75', storedetaildate = '2024-12-18 11:29: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', '149981', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-18 11:29:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36371;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('290','R3339', '149981', '1', '16438', '1', '380', '380', '0', '', '1', '2024-12-18 11:29:34', '16438', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36371-1,','1','1','0','0','380','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 290.00 , meanbuyprice = 290.00, lastbuyprice_withDiscount = 290.00, meanbuyprice_withDiscount = 290.00
        , lastbuyprice_withTax = 290, meanbuyprice_withTax = 290, lastbuyprice_withDiscountAndTax = 290
                where sellbilldetailid = 547883;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16438, '2024-12-18', 370.09900990099, 290, 290
                    , 290, 290, 290, 290
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 290, 290, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370.09900990099, sellCostBuyPrice =sellCostBuyPrice+290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+290
                            , 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
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 370.09900990099, 290, 290
                    , 290, 290, 290, 290
                    , 0, 0, 0, 0
                    , 0, 0, 0, 290, 290, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370.09900990099, sellCostBuyPrice =sellCostBuyPrice+290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+290
                            , 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;
UPDATE storedetail SET  productquantity = '26', userid = '75', storedetaildate = '2024-12-18 11:29:34' WHERE storedetailid = '16437';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16438', '1', '1', '1', '149981', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27', '26', '75', '2024-12-18 11:29:34','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', '149981', '5', '16426', '1', '420', '420', '0', '', '1', '2024-12-18 11:29:34', '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 = 547884;
 INSERT INTO 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-18', 409.05680041688, 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+409.05680041688, 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-18', 409.05680041688, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+409.05680041688, 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 = '14', userid = '75', storedetaildate = '2024-12-18 11:29:34' WHERE storedetailid = '16425';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16426', '1', '1', '1', '149981', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-18 11:29:34','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', '149981', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-18 11:29:34', '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 = 547885;
 INSERT INTO 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-18', 467.49348619072, 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+467.49348619072, 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-18', 467.49348619072, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+467.49348619072, 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 = '67', userid = '75', storedetaildate = '2024-12-18 11:29:34' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '149981', 'اضافة فاتورة مبيعات', 'sellbillController.php', '68', '67', '75', '2024-12-18 11:29:34','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', '149981', '5', '16391', '1', '510', '510', '0', '', '1', '2024-12-18 11:29:34', '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 = 547886;
 INSERT INTO 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-18', 496.71182907764, 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+496.71182907764, 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-18', 496.71182907764, 455, 455
                    , 455, 455, 455, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+496.71182907764, 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 = '13', userid = '75', storedetaildate = '2024-12-18 11:29:34' WHERE storedetailid = '16390';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16391', '1', '1', '1', '149981', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-18 11:29: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 ('0','10291', '149981', '17', '10291', '1', '38', '38', '0', '', '1', '2024-12-18 11:29:34', '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 = 98 where clientid = 149;
 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-18', 3738, 3120, 3120
                    , 3120, 3120, 3120, 3120.79
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3120, 3120, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3738, sellCostBuyPrice =sellCostBuyPrice+3120
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3120, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3120
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3120, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3120
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3120.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3120
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3120
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (149, '2024-12-18', 3738, 3120, 3120
                    , 3120, 3120, 3120, 3120.79
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3120, 3120, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3738, sellCostBuyPrice =sellCostBuyPrice+3120
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3120, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3120
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3120, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3120
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3120.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3120
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3120
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 3738, 3120, 3120
                    , 3120, 3120, 3120, 3120.79, 3120, 3120)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3738, netSellCostBuyPrice = netSellCostBuyPrice+3120
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3120
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+3120
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3120
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+3120
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+3120.79
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+3120
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+3120;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762946b782c2 and sellbillId = 149981 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 07:59:34";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:29:34", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:29: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-18 08:05:23";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:35:23", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:35:23', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676295ff09e37
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5802,@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-18 11:29:35', '0676295ff09e37', '5802', '530.00', '1752', '0', '1', '1222.00', '1222', '0', '1222', '1', '2024-12-18 11:35:23', '', '75', '0', 'مروة مايو 41', '2', '1', '3', '81', 'مروة مايو 41', '5' ,'0','','','','','-1','0','0','0','0','0','1222','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1752', userid = '75' WHERE clientid = '5802';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5802','530.00','1222','0','اضافة فاتورة مبيعات','149982', '1752', '2024-12-18 11:35:23', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1222', '0', null, '0', null, null,'', '0','1','1','1222','1','2024-12-18 11:29:35','0','0');
UPDATE client SET  inUse = 0 where clientid = 5802;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35619;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07136', '149982', '5', '16164', '1', '420', '420', '0', '', '1', '2024-12-18 11:35:23', '16164', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35619-1,','1','1','0','0','420','420','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 = 547888;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16164, '2024-12-18', 420, 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+420, 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-18', 420, 365, 365
                    , 365, 365, 365, 365
                    , 0, 0, 0, 0
                    , 0, 0, 0, 365, 365, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, 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 = '12', userid = '75', storedetaildate = '2024-12-18 11:35:23' WHERE storedetailid = '16163';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16164', '1', '1', '1', '149982', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-18 11:35:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36343;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06603', '149982', '5', '15038', '1', '290', '290', '0', '', '1', '2024-12-18 11:35:23', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36343-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 = 547889;
 INSERT INTO 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-18', 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-18', 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 = '66', userid = '75', storedetaildate = '2024-12-18 11:35:23' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '1', '1', '149982', 'اضافة فاتورة مبيعات', 'sellbillController.php', '67', '66', '75', '2024-12-18 11:35:23','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', '149982', '1', '16417', '1', '200', '200', '0', '', '1', '2024-12-18 11:35:23', '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 = 547890;
 INSERT INTO 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-18', 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-18', 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 = '75', storedetaildate = '2024-12-18 11:35:23' WHERE storedetailid = '16416';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16417', '1', '1', '1', '149982', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-18 11:35:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36429;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07307', '149982', '5', '16457', '1', '300', '300', '0', '', '1', '2024-12-18 11:35:23', '16457', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36429-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 = 547891;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16457, '2024-12-18', 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-18', 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 = '14', userid = '75', storedetaildate = '2024-12-18 11:35:23' WHERE storedetailid = '16456';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16457', '1', '1', '1', '149982', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-18 11:35: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 ('0','10291', '149982', '17', '10291', '1', '12', '12', '0', '', '1', '2024-12-18 11:35:23', '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 = 81 where clientid = 5802;
 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-18', 1222, 995, 995
                    , 996, 995, 996, 1005.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,995, 997, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1222, sellCostBuyPrice =sellCostBuyPrice+995
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+995, sellCostMeanBuyPrice = sellCostMeanBuyPrice+996
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+995, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+996
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1005.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+995
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+997
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (5802, '2024-12-18', 1222, 995, 995
                    , 996, 995, 996, 1005.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,995, 997, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1222, sellCostBuyPrice =sellCostBuyPrice+995
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+995, sellCostMeanBuyPrice = sellCostMeanBuyPrice+996
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+995, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+996
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1005.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+995
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+997
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1222, 995, 995
                    , 996, 995, 996, 1005.95, 995, 997)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1222, netSellCostBuyPrice = netSellCostBuyPrice+995
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+995
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+996
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+995
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+996
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1005.95
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+995
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+997;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676295ff09e37 and sellbillId = 149982 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:05:24";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:35:24", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:35:24', '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-18 08:05:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:35:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:35:24', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676295d49eadc
-- ----------------------------------------------------------------------------------------------------

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-18 11:28:52', '0676295d49eadc', '1', '0.00', '0', '0', '1', '640.00', '640', '640', '0', '1', '2024-12-18 11:35:25', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','640','0','','0','0','640','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','149983', '0', '2024-12-18 11:35:25', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '640', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 11:28:52','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', '149983', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-18 11:35:25', '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 = 547893;
 INSERT INTO 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-18', 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-18', 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 = '42', userid = '104', storedetaildate = '2024-12-18 11:35:25' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '149983', 'اضافة فاتورة مبيعات', 'sellbillController.php', '43', '42', '104', '2024-12-18 11:35:25','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', '149983', '5', '15165', '1', '200', '200', '0', '', '1', '2024-12-18 11:35:25', '15165', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36331-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, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 547894;
 INSERT INTO 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-18', 200, 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+200, 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-18', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 0, 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+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 11:35:25' WHERE storedetailid = '15164';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15165', '1', '1', '1', '149983', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-5', '-6', '104', '2024-12-18 11:35:25','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', '149983', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-18 11:35:25', '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 = 547895;
 INSERT INTO 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-18', 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-18', 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 = '50', userid = '104', storedetaildate = '2024-12-18 11:35:25' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '1', '149983', 'اضافة فاتورة مبيعات', 'sellbillController.php', '51', '50', '104', '2024-12-18 11:35:25','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '4130',  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 ('3490','640', '0', '1', 'اضافة فاتورة مبيعات', '149983', '4130', '2024-12-18 11:35:25', '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-18', 640, 485, 485
                    , 485, 485, 485, 485
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,485, 343, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+640, sellCostBuyPrice =sellCostBuyPrice+485
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+485, sellCostMeanBuyPrice = sellCostMeanBuyPrice+485
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+485, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+485
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+485
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+485
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+343
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 640, 485, 485
                    , 485, 485, 485, 485
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,485, 343, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+640, sellCostBuyPrice =sellCostBuyPrice+485
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+485, sellCostMeanBuyPrice = sellCostMeanBuyPrice+485
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+485, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+485
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+485
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+485
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+343
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 640, 485, 485
                    , 485, 485, 485, 485, 485, 343)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+640, netSellCostBuyPrice = netSellCostBuyPrice+485
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+485
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+485
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+485
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+485
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+485
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+485
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+343;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676295d49eadc and sellbillId = 149983 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:05:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:35:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:35:25', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:07:16";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:37:16", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:37: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 06762975c8e734
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3507,@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-18 11:35:24', '06762975c8e734', '3507', '253.00', '930', '0', '1', '677.00', '677', '0', '677', '1', '2024-12-18 11:37:16', '', '75', '0', 'هيلينا خليل B1052', '2', '1', '3', '89', 'هيلينا خليل B1052', '2' ,'0','','','','','-1','0','0','0','0','0','677','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '930', userid = '75' 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','253.00','677','0','اضافة فاتورة مبيعات','149984', '930', '2024-12-18 11:37:16', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '677', '0', null, '0', null, null,'', '0','1','1','677','1','2024-12-18 11:35:24','0','0');
UPDATE client SET  inUse = 0 where clientid = 3507;
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', '149984', '14', '16388', '1', '670', '670', '0', '', '1', '2024-12-18 11:37:16', '16388', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36146-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 = 547896;
 INSERT INTO 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-18', 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-18', 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 = '21', userid = '75', storedetaildate = '2024-12-18 11:37:17' WHERE storedetailid = '16387';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16388', '1', '1', '1', '149984', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '75', '2024-12-18 11:37: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 ('0','10291', '149984', '17', '10291', '1', '7', '7', '0', '', '1', '2024-12-18 11:37:17', '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 = 89 where clientid = 3507;
 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-18', 677, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,585, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+677, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (3507, '2024-12-18', 677, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,585, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+677, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 677, 585, 585
                    , 585, 585, 585, 585, 585, 585)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+677, netSellCostBuyPrice = netSellCostBuyPrice+585
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+585
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+585
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+585
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+585
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+585
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+585
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+585;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762975c8e734 and sellbillId = 149984 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:07:17";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:37:17", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:37: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 ('اميرة البنا 33' , '', '', '01220059380', '0', '', '0', '2024-12-18 11:38:49', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-18','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10738', '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 ('10738','0','0','0','إضافة عميل جديد','10738', '0', '2024-12-18 11:38:49', '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-18 11:38:49');
UPDATE client SET clientname = 'اميرة البنا 33', clientaddress = '', clientphone = '', clientmobile = '01220059380', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-18', 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='12542',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10738';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:12:11";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:42:11", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:42: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 0676297cda9b27
-- ----------------------------------------------------------------------------------------------------

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,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-18 11:37:17', '0676297cda9b27', '10738', '0.00', '894', '0', '1', '894.00', '894', '0', '894', '1', '2024-12-18 11:42:12', '', '75', '0', 'اميرة البنا 33', '2', '1', '3', '89', 'اميرة البنا 33', '7' ,'0','','','','','-1','0','0','0','0','0','894','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '894', userid = '75' 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','894','0','اضافة فاتورة مبيعات','149985', '894', '2024-12-18 11:42:12', '75', '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 sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149985', '1', '14756', '1', '130', '130', '0', '', '1', '2024-12-18 11:42:12', '14756', '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 = 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-18', 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-18', 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 = '1', userid = '75', storedetaildate = '2024-12-18 11:42:12' WHERE storedetailid = '14755';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14756', '1', '1', '1', '149985', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-18 11:42: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 ('220','06439', '149985', '5', '14647', '1', '185', '185', '0', '', '1', '2024-12-18 11:42:12', '14647', '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 = 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-18', 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-18', 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 = '1', userid = '75', storedetaildate = '2024-12-18 11:42:12' WHERE storedetailid = '14646';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14647', '1', '1', '1', '149985', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-18 11:42:12','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', '149985', '1', '14701', '1', '205', '205', '0', '', '1', '2024-12-18 11:42:12', '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 = 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-18', 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-18', 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 = '75', storedetaildate = '2024-12-18 11:42:12' WHERE storedetailid = '14700';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14701', '1', '1', '1', '149985', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '75', '2024-12-18 11:42:12','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', '149985', '1', '13859', '1', '145', '145', '0', '', '1', '2024-12-18 11:42:12', '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 = 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-18', 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-18', 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 = '75', storedetaildate = '2024-12-18 11:42:12' WHERE storedetailid = '13858';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13859', '1', '1', '1', '149985', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-18 11:42:12','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', '149985', '1', '14267', '1', '200', '200', '0', '', '1', '2024-12-18 11:42:12', '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 = 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-18', 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-18', 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 = '75', storedetaildate = '2024-12-18 11:42:12' WHERE storedetailid = '14266';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14267', '1', '1', '1', '149985', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-18 11:42: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', '149985', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 11:42: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', '149985', '17', '10291', '1', '9', '9', '0', '', '1', '2024-12-18 11:42:12', '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 = 89 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-18', 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-18', 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;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676297cda9b27 and sellbillId = 149985 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:12:12";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:42:12", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:42: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-18 08:20:35";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:50:35", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:50:35', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676298f5057af
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2856,@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-18 11:42:13', '0676298f5057af', '2856', '-626.00', '1808', '0', '1', '2434.00', '2434', '0', '2434', '1', '2024-12-18 11:50:35', '', '75', '0', 'رشا سمير t77', '2', '1', '3', '89', 'رشا سمير t77', '11' ,'0','','','','','-1','0','0','0','0','0','2434','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1808', userid = '75' WHERE clientid = '2856';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2856','-626.00','2434','0','اضافة فاتورة مبيعات','149986', '1808', '2024-12-18 11:50:35', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2434', '0', null, '0', null, null,'', '0','1','1','2434','1','2024-12-18 11:42:13','0','0');
UPDATE client SET  inUse = 0 where clientid = 2856;
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', '149986', '5', '16284', '1', '200', '200', '0', '', '1', '2024-12-18 11:50:35', '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 = 547905;
 INSERT INTO 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-18', 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-18', 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 = '10', userid = '75', storedetaildate = '2024-12-18 11:50:35' WHERE storedetailid = '16283';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16284', '1', '1', '1', '149986', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-18 11:50:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 35771;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149986', '5', '15674', '3', '360', '1080', '0', '', '1', '2024-12-18 11:50:35', '15674', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35771-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
                where sellbilldetailid = 547906;
 INSERT INTO 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-18', 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-18', 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 = '42', userid = '75', storedetaildate = '2024-12-18 11:50:35' WHERE storedetailid = '15673';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15674', '1', '3', '1', '149986', 'اضافة فاتورة مبيعات', 'sellbillController.php', '45', '42', '75', '2024-12-18 11:50:35','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', '149986', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-18 11:50:35', '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 = 547907;
 INSERT INTO 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-18', 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-18', 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 = '49', userid = '75', storedetaildate = '2024-12-18 11:50:35' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '1', '149986', 'اضافة فاتورة مبيعات', 'sellbillController.php', '50', '49', '75', '2024-12-18 11:50:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35692;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3305', '149986', '1', '16072', '1', '240', '240', '0', '', '1', '2024-12-18 11:50:35', '16072', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35692-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 = 547908;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16072, '2024-12-18', 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-18', 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 = '6', userid = '75', storedetaildate = '2024-12-18 11:50:35' WHERE storedetailid = '16071';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16072', '1', '1', '1', '149986', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-18 11:50:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35606;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07050', '149986', '5', '16037', '1', '210', '210', '0', '', '1', '2024-12-18 11:50:35', '16037', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35606-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 164.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 164.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 163, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 547909;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16037, '2024-12-18', 210, 165, 165
                    , 164, 165, 164, 162.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 163, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+164
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+164
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+162.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+163
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 210, 165, 165
                    , 164, 165, 164, 162.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 163, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+164
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+164
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+162.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+163
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 11:50:35' WHERE storedetailid = '16036';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16037', '1', '1', '1', '149986', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-18 11:50:35','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', '149986', '5', '15820', '1', '200', '200', '0', '', '1', '2024-12-18 11:50:35', '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 = 547910;
 INSERT INTO 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-18', 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-18', 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 = '8', userid = '75', storedetaildate = '2024-12-18 11:50:35' WHERE storedetailid = '15819';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15820', '1', '1', '1', '149986', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-18 11:50:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35505;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0K801', '149986', '7', '16098', '1', '220', '220', '0', '', '1', '2024-12-18 11:50:35', '16098', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35505-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 = 547911;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16098, '2024-12-18', 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-18', 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 = '4', userid = '75', storedetaildate = '2024-12-18 11:50:35' WHERE storedetailid = '16097';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16098', '1', '1', '1', '149986', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 11:50: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', '149986', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 11:50: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', '149986', '17', '10291', '1', '24', '24', '0', '', '1', '2024-12-18 11:50:35', '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 = 89 where clientid = 2856;
 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-18', 2434, 1905, 1905
                    , 1904, 1905, 1904, 1903.61
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1905, 1901, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2434, sellCostBuyPrice =sellCostBuyPrice+1905
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1905, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1904
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1905, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1904
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1903.61
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1905
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1901
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (2856, '2024-12-18', 2434, 1905, 1905
                    , 1904, 1905, 1904, 1903.61
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1905, 1901, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2434, sellCostBuyPrice =sellCostBuyPrice+1905
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1905, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1904
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1905, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1904
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1903.61
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1905
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1901
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 2434, 1905, 1905
                    , 1904, 1905, 1904, 1903.61, 1905, 1901)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2434, netSellCostBuyPrice = netSellCostBuyPrice+1905
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1905
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1904
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1905
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1904
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1903.61
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1905
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1901;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676298f5057af and sellbillId = 149986 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:20:36";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 11:50:36", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:50: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-18 08:26:35";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:56:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:56:35', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:26:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:56:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:56:47', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067629c536abff
-- ----------------------------------------------------------------------------------------------------

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-18 11:56:35', '067629c536abff', '1', '0.00', '0', '0', '1', '360', '360', '-360', '0', '1', '2024-12-18 11:56:47', '', '104', '0', 'نقدي','1', '0', '5', '4', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-360','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','اضافة فاتورة مردوات مبيعات','16814', '0', '2024-12-18 11:56:47', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '360', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 11:56: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 ('295.00', '06870', '16814', '5', '15653', '1', '360', '360', '0', '', '1', '0', '15653', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','360','360','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 305.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 305.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 305, lastbuyprice_withDiscountAndTax = 295
                where returnsellbilldetailid = 21996;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15653, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 295, 295, 305
                    , 295, 305, 295, 0, 1, 0, 0, 295, 305)
                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+360, returnSellCostBuyPrice = returnSellCostBuyPrice+295, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+295
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+305, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+295
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+305
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+295
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+295
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+305
                        , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 295, 295, 305
                    , 295, 305, 295, 0, 0, 295, 305)
                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+360, returnSellCostBuyPrice = returnSellCostBuyPrice+295, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+295
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+305, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+295
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+305
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+295
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+295
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+305;
UPDATE storedetail SET  productquantity = '26', userid = '104', storedetaildate = '2024-12-18 11:56:47' WHERE storedetailid = '15652';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15653', '1', '1', '0', '16814', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '25', '26', '104', '2024-12-18 11:56:47','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '3770',  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 ('4130','-360', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16814', '3770', '2024-12-18 11:56:47', '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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 295, 295, 305
                    , 295, 305, 295 ,0, 0, 295, 305)
                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+360, returnSellCostBuyPrice = returnSellCostBuyPrice+295, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+295
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+305, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+295
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+305
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+295
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+295
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+305;
 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 295, 295, 305
                    , 295, 305, 295 ,0, 0, 295, 305)
                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+360, returnSellCostBuyPrice = returnSellCostBuyPrice+295, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+295
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+305, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+295
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+305
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+295
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+295
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+305;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -360, -295, -295
                    , -305, -295, -305, -295, -295, -305)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-360, netSellCostBuyPrice = netSellCostBuyPrice+-295
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-295
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-305
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-295
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-305
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-295
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-295
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-305;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067629c536abff and sellbillId = 16814 and returnsellbillId = 16814
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:26:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:56:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 11:56:48', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:27:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:57:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 11:57:13', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:27:27";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:57:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 11:57:27', '104', 'add', '192.168.1.13', '', '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-18', '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 = '3720',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('3770.00','50', '1', '1', 'إضافة مصروف', '25817', '3720', '2024-12-18 11:57:27', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'سلمي', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-18', 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 = '25817';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:27:27";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:57:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 11:57:27', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:27:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:57:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 11:57:29', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:27:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:57:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 11:57:29', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:27:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:57:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 11:57:39', '104', 'add', '192.168.1.13', '', '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-18', '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 = '3670',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('3720.00','50', '1', '1', 'إضافة مصروف', '25818', '3670', '2024-12-18 11:57:39', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'رضا', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-18', 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 = '25818';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:27:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:57:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 11:57:39', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:27:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 11:57:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 11:57:41', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:30:06";
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-18 08:30:16";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:00:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 12:00:16', '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-18 08:30:17";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:30:38";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:00:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-18 12:00:38', '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-18 08:34:06";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:04:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:04: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-18 08:37:05";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 12:07:05", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:07: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 067629aec8fbc1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1487,@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-18 11:50:36', '067629aec8fbc1', '1487', '30.00', '444', '0', '1', '414.00', '414', '0', '414', '1', '2024-12-18 12:07:06', '', '75', '0', 'امنية محمود الشرقية Z44', '2', '1', '3', '87', 'امنية محمود الشرقية Z44', '3' ,'0','','','','','-1','0','0','0','0','0','414','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '444', userid = '75' WHERE clientid = '1487';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1487','30.00','414','0','اضافة فاتورة مبيعات','149987', '444', '2024-12-18 12:07:06', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '414', '0', null, '0', null, null,'', '0','1','1','414','1','2024-12-18 11:50:36','0','0');
UPDATE client SET  inUse = 0 where clientid = 1487;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35602;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07118', '149987', '5', '16125', '1', '200', '200', '0', '', '1', '2024-12-18 12:07:06', '16125', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35602-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 = 547914;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16125, '2024-12-18', 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-18', 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 = '75', storedetaildate = '2024-12-18 12:07:06' WHERE storedetailid = '16124';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16125', '1', '1', '1', '149987', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-18 12:07:06','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', '149987', '5', '16294', '1', '210', '210', '0', '', '1', '2024-12-18 12:07:06', '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 = 146.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 146.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 152, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 547915;
 INSERT INTO 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-18', 210, 140, 155
                    , 146, 155, 146, 152.86
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 152, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+146
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+146
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+152.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+152
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 210, 140, 155
                    , 146, 155, 146, 152.86
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 152, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+146
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+146
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+152.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+152
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '75', storedetaildate = '2024-12-18 12:07:06' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '1', '149987', 'اضافة فاتورة مبيعات', 'sellbillController.php', '73', '72', '75', '2024-12-18 12:07: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 ('0','10291', '149987', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-18 12:07:06', '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 = 87 where clientid = 1487;
 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-18', 414, 295, 310
                    , 301, 310, 301, 307.86
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,310, 307, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+414, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+301
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+301
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+307.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+307
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (1487, '2024-12-18', 414, 295, 310
                    , 301, 310, 301, 307.86
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,310, 307, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+414, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+301
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+301
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+307.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+307
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 414, 295, 310
                    , 301, 310, 301, 307.86, 310, 307)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+414, netSellCostBuyPrice = netSellCostBuyPrice+295
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+310
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+301
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+310
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+301
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+307.86
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+310
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+307;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067629aec8fbc1 and sellbillId = 149987 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:37:06";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 12:07:06", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:07: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-18 08:39:54";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:09:54", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:09:54', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247244
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8065,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 12:09:54', userid = '2' WHERE clientid = '8065';
UPDATE client SET  inUse = 0 where clientid = 8065;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8065','747.00','747','1','ايصال تحصيل (( قبض من عميل ))','247244', '0', '2024-12-18 12:04:07', '2', 'clientPayedDeptController.php', '   ', '747', '0', null, '0', null, null,'', '-1','1','1','747','1','','3482','0');
UPDATE save SET  savecurrentvalue = '179111.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('178364.50','747', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247245', '179111.5', '2024-12-18 12:09:54', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '747', '747', '2024-12-18', '2', '0', '0', '2024-12-18 12:09:54','اضافة ايصال سداد للعميل مدام ميرا ستور I1090','1','0','0','0','247245','clientPayedDeptController.php?do=show&id=247245');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122126', '-1', '747', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '747', 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 ('122126', '-1', '747', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-747', 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 = '8065', clientdebtchangebefore = '747.000', clientdebtchangeamount = '747.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247244', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 12:04:07', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '747.00',discount='', reciptid='0', dailyentryid = '122126',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='747',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247245';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247244 -clientdebtchangeId = 247245
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:39:55";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:09:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:09: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-18 08:40:29";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:10:29", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:10:29', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247246
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3653,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 12:10:29', userid = '2' WHERE clientid = '3653';
UPDATE client SET  inUse = 0 where clientid = 3653;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3653','1205.00','1205','1','ايصال تحصيل (( قبض من عميل ))','247246', '0', '2024-12-18 12:09:55', '2', 'clientPayedDeptController.php', '   ', '1205', '0', null, '0', null, null,'', '-1','1','1','1205','1','','3483','0');
UPDATE save SET  savecurrentvalue = '180316.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('179111.50','1205', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247246', '180316.5', '2024-12-18 12:10:29', '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 ('مدام شيماء 25', 'مدام شيماء 25', 'مدام شيماء 25', 'مدام شيماء 25', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-18 12:10:29');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1205', '1205', '2024-12-18', '2', '0', '0', '2024-12-18 12:10:29','اضافة ايصال سداد للعميل مدام شيماء 25','1','0','0','0','247246','clientPayedDeptController.php?do=show&id=247246');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122127', '-1', '1205', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1205', 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 ('122127', '12543', '1205', '','0');
UPDATE accountstree SET name = 'مدام شيماء 25', customName = 'مدام شيماء 25', customNameEn = 'مدام شيماء 25', nameEn = 'مدام شيماء 25', parent = '58', accountNature = '0', theValue = '-1205', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 12:10:29' WHERE id = '12543';
UPDATE clientdebtchange SET clientid = '3653', clientdebtchangebefore = '1205.000', clientdebtchangeamount = '1205.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247246', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 12:09:55', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1205.00',discount='', reciptid='0', dailyentryid = '122127',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1205',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247246';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247247
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9373,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 12:11:21', userid = '2' WHERE clientid = '9373';
UPDATE client SET  inUse = 0 where clientid = 9373;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9373','1308.00','1308','1','ايصال تحصيل (( قبض من عميل ))','247247', '0', '2024-12-18 12:10:30', '2', 'clientPayedDeptController.php', '   ', '1308', '0', null, '0', null, null,'', '-1','1','1','1308','1','','3484','0');
UPDATE save SET  savecurrentvalue = '181624.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('180316.50','1308', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247247', '181624.5', '2024-12-18 12:11:21', '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 ('سميرة رضا الشيخ K387', 'سميرة رضا الشيخ K387', 'سميرة رضا الشيخ K387', 'سميرة رضا الشيخ K387', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-18 12:11:21');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1308', '1308', '2024-12-18', '2', '0', '0', '2024-12-18 12:11:21','اضافة ايصال سداد للعميل سميرة رضا الشيخ K387','1','0','0','0','247247','clientPayedDeptController.php?do=show&id=247247');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122128', '-1', '1308', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1308', 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 ('122128', '12544', '1308', '','0');
UPDATE accountstree SET name = 'سميرة رضا الشيخ K387', customName = 'سميرة رضا الشيخ K387', customNameEn = 'سميرة رضا الشيخ K387', nameEn = 'سميرة رضا الشيخ K387', parent = '58', accountNature = '0', theValue = '-1308', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 12:11:21' WHERE id = '12544';
UPDATE clientdebtchange SET clientid = '9373', clientdebtchangebefore = '1308.000', clientdebtchangeamount = '1308.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247247', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 12:10:30', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1308.00',discount='', reciptid='0', dailyentryid = '122128',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1308',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247247';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247248
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10309,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 12:11:54', userid = '2' WHERE clientid = '10309';
UPDATE client SET  inUse = 0 where clientid = 10309;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10309','889.00','889','1','ايصال تحصيل (( قبض من عميل ))','247248', '0', '2024-12-18 12:11:22', '2', 'clientPayedDeptController.php', '   ', '889', '0', null, '0', null, null,'', '-1','1','1','889','1','','3485','0');
UPDATE save SET  savecurrentvalue = '182513.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('181624.50','889', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247248', '182513.5', '2024-12-18 12:11:54', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '889', '889', '2024-12-18', '2', '0', '0', '2024-12-18 12:11:55','اضافة ايصال سداد للعميل مدام جيهان 12','1','0','0','0','247248','clientPayedDeptController.php?do=show&id=247248');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122129', '-1', '889', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '889', 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 ('122129', '11355', '889', '','0');
UPDATE accountstree SET name = 'مدام جيهان 12', customName = 'مدام جيهان 12', customNameEn = 'مدام جيهان 12', nameEn = 'مدام جيهان 12', parent = '58', accountNature = '0', theValue = '-1838', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-11-08 12:12:02' WHERE id = '11355';
UPDATE clientdebtchange SET clientid = '10309', clientdebtchangebefore = '889.000', clientdebtchangeamount = '889.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247248', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 12:11:22', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '889.00',discount='', reciptid='0', dailyentryid = '122129',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='889',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247248';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:41:55";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:11:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:11: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-18 08:42:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:12:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:12:02', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:42:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:12:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:12:05', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=4');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:42:47";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:12:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:12:47', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247249
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5802,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 12:12:47', userid = '2' WHERE clientid = '5802';
UPDATE client SET  inUse = 0 where clientid = 5802;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5802','1752.00','1752','1','ايصال تحصيل (( قبض من عميل ))','247249', '0', '2024-12-18 12:11:55', '2', 'clientPayedDeptController.php', '   ', '1752', '0', null, '0', null, null,'', '-1','1','1','1752','1','','3486','0');
UPDATE save SET  savecurrentvalue = '184265.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('182513.50','1752', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247249', '184265.5', '2024-12-18 12:12:47', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1752', '1752', '2024-12-18', '2', '0', '0', '2024-12-18 12:12:47','اضافة ايصال سداد للعميل مروة مايو 41','1','0','0','0','247249','clientPayedDeptController.php?do=show&id=247249');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122130', '-1', '1752', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1752', 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 ('122130', '-1', '1752', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1752', 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 = '5802', clientdebtchangebefore = '1752.000', clientdebtchangeamount = '1752.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247249', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 12:11:55', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1752.00',discount='', reciptid='0', dailyentryid = '122130',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1752',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247249';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:42:48";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:12:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:12: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-18 08:43:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:13:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:13:07', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067629ff52a99a
-- ----------------------------------------------------------------------------------------------------

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-18 12:12:05', '067629ff52a99a', '1', '0.00', '0', '0', '1', '0.00', '0', '0', '0', '1', '2024-12-18 12:13:07', '', '104', '0', 'نقدي', '1', '0', '4', '0', '330', '330', 'نقدي', '1', '1', '0', '', '', '','','-1','0','0','0','','0','0','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','اضافة فاتورة مبيعات ومردودات','112', '0', '2024-12-18 12:13:07', '104', 'sellbillandruternController.php', 'اضافة فاتورة مبيعات ومردودات', '0', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 12:12:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35504;
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 ('240','0K800', '112', '7', '16097', '1', '330', '330.00', '0', '', '0', '2024-12-18 12:13:07', '0', '16097', '0.00', '-1', '1','0','','','0','0','0','0','0','0','35504-1,','1','1','','0','0','330','330','0','','','0');
UPDATE sellandruternbilldetail 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 = 294;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16097, '2024-12-18', 330, 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+330, 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-18', 330, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, 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-18 12:13:07' WHERE storedetailid = '16096';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16097', '1', '1', '1', '112', 'فاتوره مبيعات ومردودات', 'sellbillandruternController.php', '6', '5', '104', '2024-12-18 12:13:07','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 ('250.00','06956', '112', '5', '15862', '1', '330', '330', '0', '', '0', '2024-12-18 12:13:07', '1', '15862', '0.00', '-1', '1','0','','','0','0','0','0','0','0','','1','1','','0','0','330','330','0','','','0');
UPDATE sellandruternbilldetail 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 sellbilldetailid = 295;
 INSERT INTO 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-18', 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-18', 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 = '3', userid = '104', storedetaildate = '2024-12-18 12:13:07' WHERE storedetailid = '15861';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15862', '1', '1', '0', '112', 'اضافة فاتورة مردودات مبيعات', 'sellbillandruternController.php', '2', '3', '104', '2024-12-18 12:13:07','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-18', 330, 240, 240
                    , 240, 240, 240, 240
                    , 330, 250, 250, 250
                    , 250, 250, 250 ,240, 240, 250, 246)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, 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+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;
 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-18', 330, 240, 240
                    , 240, 240, 240, 240
                    , 330, 250, 250, 250
                    , 250, 250, 250 ,240, 240, 250, 246)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, 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+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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 0, -10, -10
                    , -10, -10, -10, -10, -10, -6)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+0, netSellCostBuyPrice = netSellCostBuyPrice+-10
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-10
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-10
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-10
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-10
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-10
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-10
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-6;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067629ff52a99a and sellbillId = 112 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:43:08";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:13:08", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-18 12:13:08', '104', 'editprint', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=editprint&id=112');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:43:14";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:13:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:13:14', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247250
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(149,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '1' , clientdate = '2024-12-18 12:13:14', userid = '2' WHERE clientid = '149';
UPDATE client SET  inUse = 0 where clientid = 149;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('149','3739.00','3738','1','ايصال تحصيل (( قبض من عميل ))','247250', '1', '2024-12-18 12:12:48', '2', 'clientPayedDeptController.php', '   ', '3738', '0', null, '0', null, null,'', '-1','1','1','3738','1','','3487','0');
UPDATE save SET  savecurrentvalue = '188003.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('184265.50','3738', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247251', '188003.5', '2024-12-18 12:13:14', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '3738', '3738', '2024-12-18', '2', '0', '0', '2024-12-18 12:13:14','اضافة ايصال سداد للعميل دينا المسيري z110','1','0','0','0','247251','clientPayedDeptController.php?do=show&id=247251');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122131', '-1', '3738', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '3738', 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 ('122131', '-1', '3738', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-3738', 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 = '149', clientdebtchangebefore = '3739.000', clientdebtchangeamount = '3738.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247250', clientdebtchangeafter = '1.000', clientdebtchangedate = '2024-12-18 12:12:48', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '3738.00',discount='', reciptid='0', dailyentryid = '122131',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='3738',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247251';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247250 -clientdebtchangeId = 247251
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247252
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8279,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 12:13:41', userid = '2' WHERE clientid = '8279';
UPDATE client SET  inUse = 0 where clientid = 8279;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8279','763.00','763','1','ايصال تحصيل (( قبض من عميل ))','247252', '0', '2024-12-18 12:13:14', '2', 'clientPayedDeptController.php', '   ', '763', '0', null, '0', null, null,'', '-1','1','1','763','1','','3488','0');
UPDATE save SET  savecurrentvalue = '188766.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('188003.50','763', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247252', '188766.5', '2024-12-18 12:13:41', '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-18', '2', '0', '0', '2024-12-18 12:13:41','اضافة ايصال سداد للعميل نور سوهاج T350','1','0','0','0','247252','clientPayedDeptController.php?do=show&id=247252');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122132', '-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 ('122132', '-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;
UPDATE clientdebtchange SET clientid = '8279', clientdebtchangebefore = '763.000', clientdebtchangeamount = '763.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247252', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 12:13:14', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '763.00',discount='', reciptid='0', dailyentryid = '122132',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='763',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247252';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:43:42";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:13:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:13: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-18 08:43:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:13:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:13:50', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:44:10";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:14:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:14:10', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247253
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7701,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '602' , clientdate = '2024-12-18 12:14:10', 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','1202.00','600','1','ايصال تحصيل (( قبض من عميل ))','247253', '602', '2024-12-18 12:13:42', '2', 'clientPayedDeptController.php', '   ', '600', '0', null, '0', null, null,'', '-1','1','1','600','1','','3489','0');
UPDATE save SET  savecurrentvalue = '189366.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('188766.50','600', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247253', '189366.5', '2024-12-18 12:14: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 ('الهام جمال Z1102', 'الهام جمال Z1102', 'الهام جمال Z1102', 'الهام جمال Z1102', '58', '0', '602.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-18 12:14:11');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '600', '600', '2024-12-18', '2', '0', '0', '2024-12-18 12:14:11','اضافة ايصال سداد للعميل الهام جمال Z1102','1','0','0','0','247253','clientPayedDeptController.php?do=show&id=247253');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122133', '-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 ('122133', '12545', '600', '','0');
UPDATE accountstree SET name = 'الهام جمال Z1102', customName = 'الهام جمال Z1102', customNameEn = 'الهام جمال Z1102', nameEn = 'الهام جمال Z1102', parent = '58', accountNature = '0', theValue = '2', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 12:14:11' WHERE id = '12545';
UPDATE clientdebtchange SET clientid = '7701', clientdebtchangebefore = '1202.000', clientdebtchangeamount = '600.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247253', clientdebtchangeafter = '602.000', clientdebtchangedate = '2024-12-18 12:13:42', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '600.00',discount='', reciptid='0', dailyentryid = '122133',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='600',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247253';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247254
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10735,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '20' , clientdate = '2024-12-18 12:14:37', userid = '2' WHERE clientid = '10735';
UPDATE client SET  inUse = 0 where clientid = 10735;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10735','444.00','424','1','ايصال تحصيل (( قبض من عميل ))','247254', '20', '2024-12-18 12:14:11', '2', 'clientPayedDeptController.php', '   ', '424', '0', null, '0', null, null,'', '-1','1','1','424','1','','3490','0');
UPDATE save SET  savecurrentvalue = '189790.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('189366.50','424', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247254', '189790.5', '2024-12-18 12:14:37', '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-18', '2', '0', '0', '2024-12-18 12:14:37','اضافة ايصال سداد للعميل ميرنا ابراهيم 52','1','0','0','0','247254','clientPayedDeptController.php?do=show&id=247254');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122134', '-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 ('122134', '12536', '424', '','0');
UPDATE accountstree SET name = 'ميرنا ابراهيم 52', customName = 'ميرنا ابراهيم 52', customNameEn = 'ميرنا ابراهيم 52', nameEn = 'ميرنا ابراهيم 52', parent = '58', accountNature = '0', theValue = '-424', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-17 17:39:49' WHERE id = '12536';
UPDATE clientdebtchange SET clientid = '10735', clientdebtchangebefore = '444.000', clientdebtchangeamount = '424.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247254', clientdebtchangeafter = '20.000', clientdebtchangedate = '2024-12-18 12:14:11', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '424.00',discount='', reciptid='0', dailyentryid = '122134',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='424',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247254';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:44:38";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:14:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:14: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-18 08:45:01";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:15:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:15:01', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247255
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10414,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 12:15:01', userid = '2' WHERE clientid = '10414';
UPDATE client SET  inUse = 0 where clientid = 10414;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10414','2520.00','2520','1','ايصال تحصيل (( قبض من عميل ))','247255', '0', '2024-12-18 12:14:38', '2', 'clientPayedDeptController.php', '   ', '2520', '0', null, '0', null, null,'', '-1','1','1','2520','1','','3491','0');
UPDATE save SET  savecurrentvalue = '192310.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('189790.50','2520', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247255', '192310.5', '2024-12-18 12:15:01', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '2520', '2520', '2024-12-18', '2', '0', '0', '2024-12-18 12:15:02','اضافة ايصال سداد للعميل رحمة عبد الهادي12','1','0','0','0','247255','clientPayedDeptController.php?do=show&id=247255');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122135', '-1', '2520', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '2520', 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 ('122135', '11719', '2520', '','0');
UPDATE accountstree SET name = 'رحمة عبد الهادي12', customName = 'رحمة عبد الهادي12', customNameEn = 'رحمة عبد الهادي12', nameEn = 'رحمة عبد الهادي12', parent = '58', accountNature = '0', theValue = '-4051', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '101', del = '0', sysdate = '2024-11-18 18:30:43' WHERE id = '11719';
UPDATE clientdebtchange SET clientid = '10414', clientdebtchangebefore = '2520.000', clientdebtchangeamount = '2520.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247255', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 12:14:38', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '2520.00',discount='', reciptid='0', dailyentryid = '122135',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='2520',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247255';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:45:02";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:15:02", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:15: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-18 08:45:23";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:15:23", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:15:23', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247256
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10620,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 12:15:23', userid = '2' WHERE clientid = '10620';
UPDATE client SET  inUse = 0 where clientid = 10620;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10620','712.00','712','1','ايصال تحصيل (( قبض من عميل ))','247256', '0', '2024-12-18 12:15:02', '2', 'clientPayedDeptController.php', '   ', '712', '0', null, '0', null, null,'', '-1','1','1','712','1','','3492','0');
UPDATE save SET  savecurrentvalue = '193022.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('192310.50','712', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247256', '193022.5', '2024-12-18 12:15:23', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '712', '712', '2024-12-18', '2', '0', '0', '2024-12-18 12:15:23','اضافة ايصال سداد للعميل اية امين 43','1','0','0','0','247256','clientPayedDeptController.php?do=show&id=247256');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122136', '-1', '712', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '712', 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 ('122136', '12272', '712', '','0');
UPDATE accountstree SET name = 'اية امين 43', customName = 'اية امين 43', customNameEn = 'اية امين 43', nameEn = 'اية امين 43', parent = '58', accountNature = '0', theValue = '-1212', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-06 20:31:46' WHERE id = '12272';
UPDATE clientdebtchange SET clientid = '10620', clientdebtchangebefore = '712.000', clientdebtchangeamount = '712.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247256', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 12:15:02', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '712.00',discount='', reciptid='0', dailyentryid = '122136',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='712',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247256';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:45:24";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:15:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:15: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-18 08:45:45";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:15:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:15:45', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247257
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10699,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '12' , clientdate = '2024-12-18 12:15:45', userid = '2' WHERE clientid = '10699';
UPDATE client SET  inUse = 0 where clientid = 10699;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10699','512.00','500','1','ايصال تحصيل (( قبض من عميل ))','247257', '12', '2024-12-18 12:15:24', '2', 'clientPayedDeptController.php', '   ', '500', '0', null, '0', null, null,'', '-1','1','1','500','1','','3493','0');
UPDATE save SET  savecurrentvalue = '193522.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('193022.50','500', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247257', '193522.5', '2024-12-18 12:15:45', '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-18', '2', '0', '0', '2024-12-18 12:15:45','اضافة ايصال سداد للعميل ندي محمود 52','1','0','0','0','247257','clientPayedDeptController.php?do=show&id=247257');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122137', '-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 ('122137', '12450', '500', '','0');
UPDATE accountstree SET name = 'ندي محمود 52', customName = 'ندي محمود 52', customNameEn = 'ندي محمود 52', nameEn = 'ندي محمود 52', parent = '58', accountNature = '0', theValue = '-650', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-13 15:30:52' WHERE id = '12450';
UPDATE clientdebtchange SET clientid = '10699', clientdebtchangebefore = '512.000', clientdebtchangeamount = '500.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247257', clientdebtchangeafter = '12.000', clientdebtchangedate = '2024-12-18 12:15:24', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '500.00',discount='', reciptid='0', dailyentryid = '122137',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='500',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247257';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:45:46";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:15:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:15: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-18 08:47:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:17:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:17:12', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762a05eafccc
-- ----------------------------------------------------------------------------------------------------

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-18 12:13:50', '06762a05eafccc', '1', '0.00', '0', '0', '1', '3300.00', '3300', '3300', '0', '1', '2024-12-18 12:17:12', '', '104', '0', 'نقدي', '1', '0', '3', '24', 'نقدي', '7' ,'0','','','','','-1','0','0','0','0','0','3300','0','','0','0','3300','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','149988', '0', '2024-12-18 12:17:12', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 12:13:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+4 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', '149988', '1', '16440', '4', '470', '1880', '0', '', '1', '2024-12-18 12:17:12', '16440', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36373-4,','1','1','0','0','470','1880','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 = 547917;
 INSERT INTO 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-18', 1880, 1600, 1600
                    , 1600, 1600, 1600, 1600
                    , 0, 0, 0, 0
                    , 0, 0, 0, 4, 0, 1600, 1600, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1880, sellCostBuyPrice =sellCostBuyPrice+1600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1600
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1600
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1880, 1600, 1600
                    , 1600, 1600, 1600, 1600
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1600, 1600, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1880, sellCostBuyPrice =sellCostBuyPrice+1600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1600
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1600
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 12:17:12' WHERE storedetailid = '16439';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16440', '1', '4', '1', '149988', 'اضافة فاتورة مبيعات', 'sellbillController.php', '36', '32', '104', '2024-12-18 12:17:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34434;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3205', '149988', '1', '15411', '1', '620', '620', '0', '', '1', '2024-12-18 12:17:12', '15411', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34434-1,','1','1','0','0','620','620','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 = 455, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 547918;
 INSERT INTO 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-18', 620, 550, 550
                    , 548, 550, 548, 497.74
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 550, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+548
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+548
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+497.74
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , 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-18', 620, 550, 550
                    , 548, 550, 548, 497.74
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+548
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+548
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+497.74
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , 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 = '76', userid = '104', storedetaildate = '2024-12-18 12:17:12' WHERE storedetailid = '15410';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15411', '1', '1', '1', '149988', 'اضافة فاتورة مبيعات', 'sellbillController.php', '77', '76', '104', '2024-12-18 12:17:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36078;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149988', '5', '16279', '2', '400', '800', '0', '', '1', '2024-12-18 12:17:12', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36078-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 = 285, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 547919;
 INSERT INTO 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-18', 800, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 670, 570, 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+570
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 800, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0, 670, 570, 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+570
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 12:17:12' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '2', '1', '149988', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32', '30', '104', '2024-12-18 12:17:12','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6970',  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 ('3670','3300', '0', '1', 'اضافة فاتورة مبيعات', '149988', '6970', '2024-12-18 12:17:12', '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-18', 3300, 2820, 2820
                    , 2818, 2820, 2818, 2767.74
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2820, 2625, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3300, sellCostBuyPrice =sellCostBuyPrice+2820
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2820, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2818
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2820, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2818
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2767.74
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2820
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2625
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 3300, 2820, 2820
                    , 2818, 2820, 2818, 2767.74
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2820, 2625, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3300, sellCostBuyPrice =sellCostBuyPrice+2820
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2820, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2818
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2820, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2818
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2767.74
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2820
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2625
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 3300, 2820, 2820
                    , 2818, 2820, 2818, 2767.74, 2820, 2625)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3300, netSellCostBuyPrice = netSellCostBuyPrice+2820
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2820
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2818
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2820
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2818
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2767.74
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2820
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2625;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762a05eafccc and sellbillId = 149988 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:47:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:17:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:17:13', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:47:21";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 12:17:21", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:17: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 067629ecb06ed6
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3265,@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-18 12:07:07', '067629ecb06ed6', '3265', '0.00', '859', '0', '1', '859.00', '859', '0', '859', '1', '2024-12-18 12:17:21', '', '75', '0', 'سمر محمد احمد F79', '2', '1', '3', '86', 'سمر محمد احمد F79', '4' ,'0','','','','','-1','0','0','0','0','0','859','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '859', userid = '75' WHERE clientid = '3265';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3265','0.00','859','0','اضافة فاتورة مبيعات','149989', '859', '2024-12-18 12:17:21', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '859', '0', null, '0', null, null,'', '0','1','1','859','1','2024-12-18 12:07:07','0','0');
UPDATE client SET  inUse = 0 where clientid = 3265;
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', '149989', '1', '16410', '1', '470', '470', '0', '', '1', '2024-12-18 12:17:21', '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 = 547920;
 INSERT INTO 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-18', 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-18', 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 = '10', userid = '75', storedetaildate = '2024-12-18 12:17:21' WHERE storedetailid = '16409';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16410', '1', '1', '1', '149989', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-18 12:17:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36061;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149989', '5', '15673', '1', '360', '360', '0', '', '1', '2024-12-18 12:17:21', '15673', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36061-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 = 547921;
 INSERT INTO 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-18', 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-18', 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 = '42', userid = '75', storedetaildate = '2024-12-18 12:17:21' WHERE storedetailid = '15672';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15673', '1', '1', '1', '149989', 'اضافة فاتورة مبيعات', 'sellbillController.php', '43', '42', '75', '2024-12-18 12:17: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', '149989', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 12:17:21', '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', '149989', '17', '10291', '1', '9', '9', '0', '', '1', '2024-12-18 12:17:21', '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 = 86 where clientid = 3265;
 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-18', 859, 705, 705
                    , 705, 705, 705, 705
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,705, 705, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+859, sellCostBuyPrice =sellCostBuyPrice+705
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+705, sellCostMeanBuyPrice = sellCostMeanBuyPrice+705
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+705, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+705
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+705
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+705
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+705
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (3265, '2024-12-18', 859, 705, 705
                    , 705, 705, 705, 705
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,705, 705, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+859, sellCostBuyPrice =sellCostBuyPrice+705
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+705, sellCostMeanBuyPrice = sellCostMeanBuyPrice+705
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+705, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+705
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+705
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+705
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+705
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 859, 705, 705
                    , 705, 705, 705, 705, 705, 705)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+859, netSellCostBuyPrice = netSellCostBuyPrice+705
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+705
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+705
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+705
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+705
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+705
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+705
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+705;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067629ecb06ed6 and sellbillId = 149989 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:47:22";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 12:17:22", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:17: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-18 08:49:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:19:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:19:45', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:50:27";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:20:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:20:27', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762a1c18b757
-- ----------------------------------------------------------------------------------------------------

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-18 12:19:45', '06762a1c18b757', '1', '0.00', '0', '0', '1', '970.00', '970', '970', '0', '1', '2024-12-18 12:20:27', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','970','0','','0','0','970','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','149990', '0', '2024-12-18 12:20:27', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '970', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 12:19:45','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', '149990', '5', '16418', '1', '570', '570', '0', '', '1', '2024-12-18 12:20:27', '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 = 547924;
 INSERT INTO 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-18', 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-18', 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 = '4', userid = '104', storedetaildate = '2024-12-18 12:20:27' WHERE storedetailid = '16417';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16418', '1', '1', '1', '149990', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-18 12:20:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '149990', '5', '16293', '2', '200', '400', '0', '', '1', '2024-12-18 12:20:27', '16293', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36003-2,','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 = 547925;
 INSERT INTO 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-18', 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-18', 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 = '40', userid = '104', storedetaildate = '2024-12-18 12:20:27' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '2', '1', '149990', 'اضافة فاتورة مبيعات', 'sellbillController.php', '42', '40', '104', '2024-12-18 12:20:27','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '7940',  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 ('6970','970', '0', '1', 'اضافة فاتورة مبيعات', '149990', '7940', '2024-12-18 12:20:27', '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-18', 970, 805, 805
                    , 805, 805, 805, 805
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,805, 805, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+970, 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 (1, '2024-12-18', 970, 805, 805
                    , 805, 805, 805, 805
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,805, 805, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+970, 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, 970, 805, 805
                    , 805, 805, 805, 805, 805, 805)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+970, 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 06762a1c18b757 and sellbillId = 149990 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067628ec3abb43
-- ----------------------------------------------------------------------------------------------------

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-18 10:58:43', '067628ec3abb43', '1', '0.00', '0', '0', '1', '1470.00', '1470', '1470', '0', '1', '2024-12-18 12:21:52', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1470','0','','0','0','1470','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','149991', '0', '2024-12-18 12:21:52', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1470', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 10:58:43','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35566;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06870', '149991', '5', '15653', '1', '360', '360', '0', '', '1', '2024-12-18 12:21:52', '15653', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35566-1,','1','1','0','0','360','360','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 305.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 305.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 305, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 547926;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15653, '2024-12-18', 360, 295, 295
                    , 305, 295, 305, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 305, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+305
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+305
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+305
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 360, 295, 295
                    , 305, 295, 305, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 305, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+305
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+305
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+305
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '104', storedetaildate = '2024-12-18 12:21:52' WHERE storedetailid = '15652';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15653', '1', '1', '1', '149991', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '104', '2024-12-18 12:21:52','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35831;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07177', '149991', '5', '16245', '1', '300', '300', '0', '', '1', '2024-12-18 12:21:52', '16245', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35831-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 = 547927;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16245, '2024-12-18', 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-18', 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 = '20', userid = '104', storedetaildate = '2024-12-18 12:21:52' WHERE storedetailid = '16244';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16245', '1', '1', '1', '149991', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '104', '2024-12-18 12:21:52','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35968;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149991', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-18 12:21:52', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35968-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 = 547928;
 INSERT INTO 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-18', 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-18', 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 = '55', userid = '104', storedetaildate = '2024-12-18 12:21:52' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '149991', 'اضافة فاتورة مبيعات', 'sellbillController.php', '56', '55', '104', '2024-12-18 12:21:52','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '9410',  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 ('7940','1470', '0', '1', 'اضافة فاتورة مبيعات', '149991', '9410', '2024-12-18 12:21:52', '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-18', 1470, 1265, 1265
                    , 1275, 1265, 1275, 1265
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1265, 1275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1470, sellCostBuyPrice =sellCostBuyPrice+1265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1275
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1275
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1470, 1265, 1265
                    , 1275, 1265, 1275, 1265
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1265, 1275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1470, sellCostBuyPrice =sellCostBuyPrice+1265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1275
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1275
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1265
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1470, 1265, 1265
                    , 1275, 1265, 1275, 1265, 1265, 1275)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1470, netSellCostBuyPrice = netSellCostBuyPrice+1265
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1265
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1275
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1265
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1275
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1265
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1265
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1275;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067628ec3abb43 and sellbillId = 149991 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762a129811f9
-- ----------------------------------------------------------------------------------------------------

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-18 12:17:13', '06762a129811f9', '1', '0.00', '0', '20', '1', '340.00', '320', '320', '0', '1', '2024-12-18 12:22:35', '', '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-18','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','اضافة فاتورة مبيعات','149992', '0', '2024-12-18 12:22:35', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '320', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 12:17:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36370;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3338', '149992', '1', '16437', '1', '340', '340', '0', '', '1', '2024-12-18 12:22:35', '16437', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36370-1,','1','1','0','0','340','340','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 = 547929;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16437, '2024-12-18', 320, 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+320, 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-18', 320, 285, 285
                    , 285, 285, 285, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0, 285, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, 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 = '26', userid = '104', storedetaildate = '2024-12-18 12:22:35' WHERE storedetailid = '16436';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16437', '1', '1', '1', '149992', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27', '26', '104', '2024-12-18 12:22:35','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '9730',  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 ('9410','320', '0', '1', 'اضافة فاتورة مبيعات', '149992', '9730', '2024-12-18 12:22:35', '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-18', 320, 285, 285
                    , 285, 285, 285, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,285, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, 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-18', 320, 285, 285
                    , 285, 285, 285, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,285, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, 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, 320, 285, 285
                    , 285, 285, 285, 285, 285, 285)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+320, 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 06762a129811f9 and sellbillId = 149992 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762a24126ce8
-- ----------------------------------------------------------------------------------------------------

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-18 12:21:53', '06762a24126ce8', '1', '0.00', '0', '0', '1', '765.00', '765', '765', '0', '1', '2024-12-18 12:22:58', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','765','0','','0','0','765','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','149993', '0', '2024-12-18 12:22:58', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '765', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 12:21:53','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', '149993', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-18 12:22:58', '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 = 285, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 547930;
 INSERT INTO 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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 285, 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+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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 285, 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+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 = '29', userid = '104', storedetaildate = '2024-12-18 12:22:58' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '149993', 'اضافة فاتورة مبيعات', 'sellbillController.php', '30', '29', '104', '2024-12-18 12:22:58','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35975;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149993', '1', '16322', '1', '365', '365', '0', '', '1', '2024-12-18 12:22:58', '16322', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35975-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 = 547931;
 INSERT INTO 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-18', 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-18', 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 = '30', userid = '104', storedetaildate = '2024-12-18 12:22:58' WHERE storedetailid = '16321';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16322', '1', '1', '1', '149993', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31', '30', '104', '2024-12-18 12:22:58','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '10495',  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 ('9730','765', '0', '1', 'اضافة فاتورة مبيعات', '149993', '10495', '2024-12-18 12:22:58', '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-18', 765, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,630, 580, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+765, sellCostBuyPrice =sellCostBuyPrice+630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+580
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 765, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,630, 580, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+765, sellCostBuyPrice =sellCostBuyPrice+630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+580
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 765, 630, 630
                    , 630, 630, 630, 630, 630, 580)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+765, netSellCostBuyPrice = netSellCostBuyPrice+630
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+630
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+630
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+630
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+630
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+630
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+630
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+580;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762a24126ce8 and sellbillId = 149993 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:52:58";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:22:58", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:22:58', '104', 'addsellBill', '192.168.1.13', '', '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 ('ندا طارق 100' , '', '', '01113472486', '0', '', '0', '2024-12-18 12:23:20', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-18','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10739', '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 ('10739','0','0','0','إضافة عميل جديد','10739', '0', '2024-12-18 12:23: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 ('ندا طارق 100', 'ندا طارق 100', 'ندا طارق 100', 'ندا طارق 100', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-18 12:23:20');
UPDATE client SET clientname = 'ندا طارق 100', clientaddress = '', clientphone = '', clientmobile = '01113472486', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-18', 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='12546',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10739';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:55:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:25:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 12:25:31', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:56:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:26:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:26:19', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:57:05";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 12:27:05", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:27: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 06762a13277f02
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10739,@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-18 12:17:22', '06762a13277f02', '10739', '0.00', '3955', '0', '1', '3955.00', '3955', '0', '3955', '1', '2024-12-18 12:27:05', '', '75', '0', 'ندا طارق 100', '2', '1', '3', '83', 'ندا طارق 100', '14' ,'0','','','','','-1','0','0','0','0','0','3955','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '3955', userid = '75' WHERE clientid = '10739';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10739','0.00','3955','0','اضافة فاتورة مبيعات','149994', '3955', '2024-12-18 12:27:05', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3955', '0', null, '0', null, null,'', '0','1','1','3955','1','2024-12-18 12:17:22','0','0');
UPDATE client SET  inUse = 0 where clientid = 10739;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 21991;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1155', '149994', '14', '9912', '2', '410', '820', '0', '', '1', '2024-12-18 12:27:05', '9912', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','21991-2,','1','1','0','0','410','820','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 264.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 264.00
        
                where sellbilldetailid = 547932;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9912, '2024-12-18', 820, 530, 530
                    , 528, 530, 528, 526.66
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+820, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+528
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+528
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+526.66
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 820, 530, 530
                    , 528, 530, 528, 526.66
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+820, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+528
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+528
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+526.66
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 12:27:05' WHERE storedetailid = '9911';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9912', '1', '2', '1', '149994', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '7', '75', '2024-12-18 12:27:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34138;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1334', '149994', '14', '15412', '1', '490', '490', '0', '', '1', '2024-12-18 12:27:06', '15412', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34138-1,','1','1','0','0','490','490','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
        
                where sellbilldetailid = 547933;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15412, '2024-12-18', 490, 390, 390
                    , 390, 390, 390, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , 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-18', 490, 390, 390
                    , 390, 390, 390, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , 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 = '1', userid = '75', storedetaildate = '2024-12-18 12:27:06' WHERE storedetailid = '15411';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15412', '1', '1', '1', '149994', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-18 12:27:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30737;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06112', '149994', '5', '13831', '1', '420', '420', '0', '', '1', '2024-12-18 12:27:06', '13831', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30737-1,','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
        
                where sellbilldetailid = 547934;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13831, '2024-12-18', 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-18', 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 = '8', userid = '75', storedetaildate = '2024-12-18 12:27:06' WHERE storedetailid = '13830';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13831', '1', '1', '1', '149994', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-18 12:27:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35775;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2932', '149994', '1', '14437', '1', '185', '185', '0', '', '1', '2024-12-18 12:27:06', '14437', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35775-1,','1','1','0','0','185','185','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 = 550, lastbuyprice_withDiscountAndTax = 220
                where sellbilldetailid = 547935;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14437, '2024-12-18', 185, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 220, 550, 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+220
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 185, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 550, 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+220
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 12:27:06' WHERE storedetailid = '14436';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14437', '1', '1', '1', '149994', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-18 12:27:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36317;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07199', '149994', '5', '16299', '1', '200', '200', '0', '', '1', '2024-12-18 12:27:06', '16299', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36317-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 = 547936;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16299, '2024-12-18', 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-18', 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 = '13', userid = '75', storedetaildate = '2024-12-18 12:27:06' WHERE storedetailid = '16298';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16299', '1', '1', '1', '149994', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-18 12:27:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36087;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07180', '149994', '5', '16264', '2', '450', '900', '0', '', '1', '2024-12-18 12:27:06', '16264', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36087-2,','1','1','0','0','450','900','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 387.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 387.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 387, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 547937;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16264, '2024-12-18', 900, 800, 800
                    , 774, 800, 774, 770
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 800, 774, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+800, sellCostMeanBuyPrice = sellCostMeanBuyPrice+774
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+774
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+770
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+800
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+774
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 900, 800, 800
                    , 774, 800, 774, 770
                    , 0, 0, 0, 0
                    , 0, 0, 0, 800, 774, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+800
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+800, sellCostMeanBuyPrice = sellCostMeanBuyPrice+774
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+800, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+774
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+770
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+800
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+774
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 12:27:06' WHERE storedetailid = '16263';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16264', '1', '2', '1', '149994', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '13', '75', '2024-12-18 12:27:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '149994', '1', '16446', '2', '160', '320', '0', '', '1', '2024-12-18 12:27:06', '16446', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36381-2,','1','1','0','0','160','320','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 = 547938;
 INSERT INTO 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-18', 320, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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+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-18', 320, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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 = '12', userid = '75', storedetaildate = '2024-12-18 12:27:06' WHERE storedetailid = '16445';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16446', '1', '2', '1', '149994', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '12', '75', '2024-12-18 12:27:06','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', '149994', '5', '16152', '1', '240', '240', '0', '', '1', '2024-12-18 12:27:06', '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 = 547939;
 INSERT INTO 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-18', 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-18', 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 = '28', userid = '75', storedetaildate = '2024-12-18 12:27:06' WHERE storedetailid = '16151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16152', '1', '1', '1', '149994', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29', '28', '75', '2024-12-18 12:27:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36177;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07279', '149994', '5', '16403', '1', '320', '320', '0', '', '1', '2024-12-18 12:27:06', '16403', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36177-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 = 133, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 547940;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16403, '2024-12-18', 320, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 265, 133, 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+133
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 320, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 133, 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+133
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 12:27:06' WHERE storedetailid = '16402';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16403', '1', '1', '1', '149994', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-18 12:27: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', '149994', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 12:27: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', '149994', '17', '10291', '1', '40', '40', '0', '', '1', '2024-12-18 12:27:06', '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 client SET  delegateid = 83 where clientid = 10739;
 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-18', 3955, 3260, 3260
                    , 3232, 3260, 3232, 3226.66
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1845, 2017, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3955, sellCostBuyPrice =sellCostBuyPrice+3260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3232
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3232
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3226.66
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1845
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2017
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (10739, '2024-12-18', 3955, 3260, 3260
                    , 3232, 3260, 3232, 3226.66
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1845, 2017, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3955, sellCostBuyPrice =sellCostBuyPrice+3260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3232
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3232
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3226.66
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1845
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2017
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 3955, 3260, 3260
                    , 3232, 3260, 3232, 3226.66, 1845, 2017)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3955, netSellCostBuyPrice = netSellCostBuyPrice+3260
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3260
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+3232
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3260
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+3232
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+3226.66
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1845
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2017;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762a13277f02 and sellbillId = 149994 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:57:06";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 12:27:06", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:27: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-18 08:58:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:28:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:28:20', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762a34b3e8e1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7372,@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-18 12:26:19', '06762a34b3e8e1', '7372', '0.00', '818', '0', '1', '818.00', '818', '0', '818', '1', '2024-12-18 12:28:20', '', '104', '0', 'محمود نبيل برافو', '1', '1', '3', '24', 'محمود نبيل برافو', '2' ,'0','','','','','-1','0','0','0','0','0','818','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '818', userid = '104' WHERE clientid = '7372';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7372','0.00','818','0','اضافة فاتورة مبيعات','149995', '818', '2024-12-18 12:28:20', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '818', '0', null, '0', null, null,'', '0','1','1','818','1','2024-12-18 12:26:19','0','0');
UPDATE client SET  inUse = 0 where clientid = 7372;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35968;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149995', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-18 12:28:20', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35968-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 = 547943;
 INSERT INTO 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-18', 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-18', 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 = '54', userid = '104', storedetaildate = '2024-12-18 12:28:20' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '149995', 'اضافة فاتورة مبيعات', 'sellbillController.php', '55', '54', '104', '2024-12-18 12:28: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 ('0','10291', '149995', '17', '10291', '1', '8', '8', '0', '', '1', '2024-12-18 12:28:20', '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 = 24 where clientid = 7372;
 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-18', 818, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+818, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7372, '2024-12-18', 818, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+818, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 818, 730, 730
                    , 730, 730, 730, 730, 730, 730)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+818, 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 06762a34b3e8e1 and sellbillId = 149995 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 08:58:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:28:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:28:21', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:04:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:34:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 12:34:29', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:04:37";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:34:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 12:34:37', '104', 'add', '192.168.1.13', '', '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-18', '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 = '10295',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('10495.00','200', '1', '1', 'إضافة مصروف', '25819', '10295', '2024-12-18 12:34:37', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'دنيا عماد', expensesdetails = '', expensesValue = '200.00', expensesdate = '2024-12-18', 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 = '25819';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:04:37";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:34:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 12:34:37', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:04:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:34:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 12:34:39', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:04:42";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:34:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:34:42', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247258
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7372,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 12:34:42', userid = '2' WHERE clientid = '7372';
UPDATE client SET  inUse = 0 where clientid = 7372;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7372','818.00','818','1','ايصال تحصيل (( قبض من عميل ))','247258', '0', '2024-12-18 12:15:46', '2', 'clientPayedDeptController.php', '   ', '818', '0', null, '0', null, null,'', '-1','1','1','818','1','','3494','0');
UPDATE save SET  savecurrentvalue = '194340.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('193522.50','818', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247267', '194340.5', '2024-12-18 12:34:42', '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-18 12:34:42');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '818', '818', '2024-12-18', '2', '0', '0', '2024-12-18 12:34:42','اضافة ايصال سداد للعميل محمود نبيل برافو','1','0','0','0','247267','clientPayedDeptController.php?do=show&id=247267');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122138', '-1', '818', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '818', 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 ('122138', '12547', '818', '','0');
UPDATE accountstree SET name = 'محمود نبيل برافو', customName = 'محمود نبيل برافو', customNameEn = 'محمود نبيل برافو', nameEn = 'محمود نبيل برافو', parent = '58', accountNature = '0', theValue = '-818', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 12:34:42' WHERE id = '12547';
UPDATE clientdebtchange SET clientid = '7372', clientdebtchangebefore = '818.000', clientdebtchangeamount = '818.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247258', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 12:15:46', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '818.00',discount='', reciptid='0', dailyentryid = '122138',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='818',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247267';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247258 -clientdebtchangeId = 247267
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:04:43";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:34:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:34: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-18 09:05:14";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:35:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:35:14', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247268
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3265,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 12:35:14', userid = '2' WHERE clientid = '3265';
UPDATE client SET  inUse = 0 where clientid = 3265;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3265','859.00','859','1','ايصال تحصيل (( قبض من عميل ))','247268', '0', '2024-12-18 12:34:43', '2', 'clientPayedDeptController.php', '   ', '859', '0', null, '0', null, null,'', '-1','1','1','859','1','','3495','0');
UPDATE save SET  savecurrentvalue = '195199.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('194340.50','859', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247268', '195199.5', '2024-12-18 12:35:14', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '859', '859', '2024-12-18', '2', '0', '0', '2024-12-18 12:35:14','اضافة ايصال سداد للعميل سمر محمد احمد F79','1','0','0','0','247268','clientPayedDeptController.php?do=show&id=247268');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122139', '-1', '859', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '859', 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 ('122139', '-1', '859', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-859', 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 = '3265', clientdebtchangebefore = '859.000', clientdebtchangeamount = '859.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247268', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 12:34:43', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '859.00',discount='', reciptid='0', dailyentryid = '122139',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='859',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247268';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:05:15";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:35:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:35:15', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:11:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:41:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:41:22', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:12:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:42:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:42:11', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762a6d28c4ea
-- ----------------------------------------------------------------------------------------------------

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-18 12:41:22', '06762a6d28c4ea', '1', '0.00', '0', '0', '1', '590.00', '590', '590', '0', '1', '2024-12-18 12:42:11', '', '104', '0', 'نقدي', '1', '0', '3', '54', 'نقدي', '2' ,'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-18','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','اضافة فاتورة مبيعات','149996', '0', '2024-12-18 12:42:11', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '590', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 12:41:22','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36343;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06603', '149996', '5', '15038', '1', '290', '290', '0', '', '1', '2024-12-18 12:42:11', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36343-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 = 547945;
 INSERT INTO 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-18', 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-18', 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 = '65', userid = '104', storedetaildate = '2024-12-18 12:42:11' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '1', '1', '149996', 'اضافة فاتورة مبيعات', 'sellbillController.php', '66', '65', '104', '2024-12-18 12:42:11','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', '149996', '5', '16239', '1', '300', '300', '0', '', '1', '2024-12-18 12:42:11', '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 = 547946;
 INSERT INTO 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-18', 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-18', 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-18 12:42:11' WHERE storedetailid = '16238';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16239', '1', '1', '1', '149996', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '104', '2024-12-18 12:42:11','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '10885',  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 ('10295','590', '0', '1', 'اضافة فاتورة مبيعات', '149996', '10885', '2024-12-18 12:42:11', '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-18', 590, 465, 465
                    , 466, 465, 466, 475.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,465, 467, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+590, sellCostBuyPrice =sellCostBuyPrice+465
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+465, sellCostMeanBuyPrice = sellCostMeanBuyPrice+466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+465, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+475.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+465
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+467
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 590, 465, 465
                    , 466, 465, 466, 475.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,465, 467, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+590, sellCostBuyPrice =sellCostBuyPrice+465
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+465, sellCostMeanBuyPrice = sellCostMeanBuyPrice+466
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+465, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+466
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+475.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+465
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+467
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 465, 465
                    , 466, 465, 466, 475.95, 465, 467)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+590, netSellCostBuyPrice = netSellCostBuyPrice+465
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+465
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+466
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+465
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+466
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+475.95
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+465
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+467;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762a6d28c4ea and sellbillId = 149996 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:12:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:42:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:42:12', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:16:03";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 12:46:03", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:46:03', '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-18 09:18:13";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:48:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:48:13', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247269
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2327,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 12:48:13', userid = '2' WHERE clientid = '2327';
UPDATE client SET  inUse = 0 where clientid = 2327;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2327','1530.00','1530','1','ايصال تحصيل (( قبض من عميل ))','247269', '0', '2024-12-18 12:35:15', '2', 'clientPayedDeptController.php', '   ', '1530', '0', null, '0', null, null,'', '-1','1','1','1530','1','','3496','0');
UPDATE save SET  savecurrentvalue = '196729.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('195199.50','1530', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247270', '196729.5', '2024-12-18 12:48:13', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1530', '1530', '2024-12-18', '2', '0', '0', '2024-12-18 12:48:13','اضافة ايصال سداد للعميل ميادة السيد k63','1','0','0','0','247270','clientPayedDeptController.php?do=show&id=247270');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122140', '-1', '1530', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1530', 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 ('122140', '-1', '1530', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1530', 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 = '2327', clientdebtchangebefore = '1530.000', clientdebtchangeamount = '1530.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247269', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 12:35:15', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1530.00',discount='', reciptid='0', dailyentryid = '122140',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1530',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247270';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247269 -clientdebtchangeId = 247270
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247271
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1487,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 12:48:41', userid = '2' WHERE clientid = '1487';
UPDATE client SET  inUse = 0 where clientid = 1487;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1487','444.00','444','1','ايصال تحصيل (( قبض من عميل ))','247271', '0', '2024-12-18 12:48:14', '2', 'clientPayedDeptController.php', '   ', '444', '0', null, '0', null, null,'', '-1','1','1','444','1','','3497','0');
UPDATE save SET  savecurrentvalue = '197173.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('196729.50','444', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247271', '197173.5', '2024-12-18 12:48:41', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '444', '444', '2024-12-18', '2', '0', '0', '2024-12-18 12:48:41','اضافة ايصال سداد للعميل امنية محمود الشرقية Z44','1','0','0','0','247271','clientPayedDeptController.php?do=show&id=247271');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122141', '-1', '444', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '444', 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 ('122141', '-1', '444', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-444', 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 = '1487', clientdebtchangebefore = '444.000', clientdebtchangeamount = '444.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247271', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 12:48:14', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '444.00',discount='', reciptid='0', dailyentryid = '122141',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='444',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247271';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:18:42";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 12:48:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:48: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-18 09:19:53";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 12:49:53", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:49: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 06762a7eb51f85
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2643,@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-18 12:46:03', '06762a7eb51f85', '2643', '3.00', '478', '0', '1', '475.00', '475', '0', '475', '1', '2024-12-18 12:49:53', '', '75', '0', 'مريم ابراهيم f139', '2', '1', '3', '86', 'مريم ابراهيم f139', '4' ,'0','','','','','-1','0','0','0','0','0','475','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '478', userid = '75' WHERE clientid = '2643';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2643','3.00','475','0','اضافة فاتورة مبيعات','149997', '478', '2024-12-18 12:49:53', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '475', '0', null, '0', null, null,'', '0','1','1','475','1','2024-12-18 12:46:03','0','0');
UPDATE client SET  inUse = 0 where clientid = 2643;
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', '149997', '14', '16298', '1', '250', '250', '0', '', '1', '2024-12-18 12:49:53', '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 = 547947;
 INSERT INTO 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-18', 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-18', 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 = '33', userid = '75', storedetaildate = '2024-12-18 12:49:53' WHERE storedetailid = '16297';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16298', '1', '1', '1', '149997', 'اضافة فاتورة مبيعات', 'sellbillController.php', '34', '33', '75', '2024-12-18 12:49:53','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', '149997', '1', '16417', '1', '200', '200', '0', '', '1', '2024-12-18 12:49:53', '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 = 547948;
 INSERT INTO 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-18', 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-18', 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 = '7', userid = '75', storedetaildate = '2024-12-18 12:49: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', '149997', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-18 12:49: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', '149997', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 12:49: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', '149997', '17', '10291', '1', '5', '5', '0', '', '1', '2024-12-18 12:49:53', '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 = 86 where clientid = 2643;
 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-18', 475, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+475, 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 (2643, '2024-12-18', 475, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+475, 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, 475, 350, 350
                    , 350, 350, 350, 350, 350, 350)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+475, 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 06762a7eb51f85 and sellbillId = 149997 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:19:54";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 12:49:54", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:49: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-18 09:23:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:53:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:53:22', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=4');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:26:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:56:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:56:54', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762a9a282cd6
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5150,@clientdebt,@clientname,@treeIdis);
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-18 12:53:22', '06762a9a282cd6', '5150', '0.00', '950', '0', '1', '950.00', '950', '0', '950', '1', '2024-12-18 12:56:54', '', '104', '0', 'اسماء النمرT33', '1', '1', '4', '0', '950', '0', 'اسماء النمرT33', '2', '0', '0', '', '', '','','-1','0','0','0','','0','0','0','0','0','0','0','0','0','1','-1','0','1','0','','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '950', userid = '104' WHERE clientid = '5150';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5150','0.00','950','0','اضافة فاتورة مبيعات ومردودات','113', '950', '2024-12-18 12:56:54', '104', 'sellbillandruternController.php', 'اضافة فاتورة مبيعات ومردودات', '950', '0', null, '0', null, null,'', '0','1','1','950','1','2024-12-18 12:53:22','0','0');
UPDATE client SET  inUse = 0 where clientid = 5150;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36152;
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 ('240','07216', '113', '5', '16314', '1', '300', '300.00', '0', '', '0', '2024-12-18 12:56:54', '0', '16314', '0.00', '-1', '1','0','','','0','0','0','0','0','0','36152-1,','1','1','','0','0','300','300','0','','','0');
UPDATE sellandruternbilldetail 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 = 296;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16314, '2024-12-18', 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-18', 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 = '14', userid = '104', storedetaildate = '2024-12-18 12:56:54' WHERE storedetailid = '16313';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16314', '1', '1', '1', '113', 'فاتوره مبيعات ومردودات', 'sellbillandruternController.php', '15', '14', '104', '2024-12-18 12:56:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35969;
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 ('550','R3327', '113', '1', '16277', '1', '650', '650.00', '0', '', '0', '2024-12-18 12:56:54', '0', '16277', '0.00', '-1', '1','0','','','0','0','0','0','0','0','35969-1,','1','1','','0','0','650','650','0','','','0');
UPDATE sellandruternbilldetail 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 = 297;
 INSERT INTO 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-18', 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-18', 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 = '52', userid = '104', storedetaildate = '2024-12-18 12:56:54' WHERE storedetailid = '16276';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16277', '1', '1', '1', '113', 'فاتوره مبيعات ومردودات', 'sellbillandruternController.php', '53', '52', '104', '2024-12-18 12:56:54','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-18', 950, 790, 790
                    , 789, 790, 787, 786.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,790, 788, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+789
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+787
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+786.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+790
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+788
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (5150, '2024-12-18', 950, 790, 790
                    , 789, 790, 787, 786.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,790, 788, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+789
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+787
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+786.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+790
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+788
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 790, 790
                    , 789, 790, 787, 786.67, 790, 788)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+950, netSellCostBuyPrice = netSellCostBuyPrice+790
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+790
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+789
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+790
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+787
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+786.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+790
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+788;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762a9a282cd6 and sellbillId = 113 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:26:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:56:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-18 12:56:55', '104', 'editprint', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=editprint&id=113');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:27:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:57:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:57:09', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:27:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:57:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 12:57:25', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762aa853d9b2
-- ----------------------------------------------------------------------------------------------------

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-18 12:57:09', '06762aa853d9b2', '1', '0.00', '0', '0', '1', '470', '470', '-470', '0', '1', '2024-12-18 12:57:26', '', '104', '0', 'نقدي','1', '0', '5', '25', 'نقدي', '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','اضافة فاتورة مردوات مبيعات','16815', '0', '2024-12-18 12:57:26', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '470', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 12:57: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 ('390.00', 'H1423', '16815', '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 = 21997;
 INSERT INTO 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-18', 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-18', 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 = '66', userid = '104', storedetaildate = '2024-12-18 12:57:26' WHERE storedetailid = '15708';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15709', '1', '1', '0', '16815', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '65', '66', '104', '2024-12-18 12:57:26','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '10415',  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 ('10885','-470', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16815', '10415', '2024-12-18 12:57:26', '104',  'returnsellbillController.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-18', 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-18', 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 06762aa853d9b2 and sellbillId = 16815 and returnsellbillId = 16815
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247275
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5150,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '480' , clientdate = '2024-12-18 12:58:17', userid = '104' WHERE clientid = '5150';
UPDATE client SET  inUse = 0 where clientid = 5150;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5150','950.00','470','1','ايصال تحصيل (( قبض من عميل ))','247275', '480', '2024-12-18 12:57:58', '104', 'clientPayedDeptController.php', '   ', '470', '0', null, '0', null, null,'', '-1','1','1','470','1','','3498','0');
UPDATE save SET  savecurrentvalue = '10885',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('10415.00','470', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '247275', '10885', '2024-12-18 12:58:17', '104',  '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-18', '104', '0', '0', '2024-12-18 12:58:17','اضافة ايصال سداد للعميل اسماء النمرT33','1','0','-1','0','247275','clientPayedDeptController.php?do=show&id=247275');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122142', '-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 ('122142', '-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;
UPDATE clientdebtchange SET clientid = '5150', clientdebtchangebefore = '950.000', clientdebtchangeamount = '470.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247275', clientdebtchangeafter = '480.000', clientdebtchangedate = '2024-12-18 12:57:58', userid = '104', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '470.00',discount='', reciptid='0', dailyentryid = '122142',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='470',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247275';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:28:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:58:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:58:18', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:28:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 12:58:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 12:58:19', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:33:00";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 13:03:00", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:03:00', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762a8d2c13ec
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6971,@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-18 12:49:54', '06762a8d2c13ec', '6971', '4.00', '671', '0', '1', '667.00', '667', '0', '667', '1', '2024-12-18 13:03:00', '', '75', '0', 'جهاد عبدالعزيز X65', '2', '1', '3', '85', 'جهاد عبدالعزيز X65', '3' ,'0','','','','','-1','0','0','0','0','0','667','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '671', userid = '75' WHERE clientid = '6971';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6971','4.00','667','0','اضافة فاتورة مبيعات','149998', '671', '2024-12-18 13:03:00', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '667', '0', null, '0', null, null,'', '0','1','1','667','1','2024-12-18 12:49:54','0','0');
UPDATE client SET  inUse = 0 where clientid = 6971;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1125', '149998', '14', '9701', '1', '640', '640', '0', '', '1', '2024-12-18 13:03:00', '9701', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','640','640','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 510.00 , meanbuyprice = 505.00, lastbuyprice_withDiscount = 510.00, meanbuyprice_withDiscount = 505.00
        
                where sellbilldetailid = 547951;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9701, '2024-12-18', 640, 510, 510
                    , 505, 510, 505, 501.54
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+640, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+501.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 640, 510, 510
                    , 505, 510, 505, 501.54
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+640, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+501.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 13:03:00' WHERE storedetailid = '9700';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9701', '1', '1', '1', '149998', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-2', '-3', '75', '2024-12-18 13:03:00','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', '149998', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 13:03:00', '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', '149998', '17', '10291', '1', '7', '7', '0', '', '1', '2024-12-18 13:03:00', '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 = 85 where clientid = 6971;
 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-18', 667, 510, 510
                    , 505, 510, 505, 501.54
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+667, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+501.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (6971, '2024-12-18', 667, 510, 510
                    , 505, 510, 505, 501.54
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+667, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+501.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 667, 510, 510
                    , 505, 510, 505, 501.54, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+667, netSellCostBuyPrice = netSellCostBuyPrice+510
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+510
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+505
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+510
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+505
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+501.54
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762a8d2c13ec and sellbillId = 149998 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:33:01";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 13:03:01", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:03:01', '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-18 09:33:35";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 13:03:35", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:03:35', '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-18 09:33:50";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 13:03:50", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:03:50', '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-18 09:34:28";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 13:04:28", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:04:28', '2', 'delete', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=delete&sellbillid=146652&action=0');

-- ----------------------------------------------------------------------------------------------------
-- bill delete start - sellbill with id = 146652
-- ----------------------------------------------------------------------------------------------------

BEGIN;
UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 146652;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 13:04:28', userid = '75',delbyuserid = '2', conditions = '1'  ,billReservation= 0,billReservationDate='0000-00-00'  WHERE sellbillid = '146652';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 30964;
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 264.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 264.00
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 66, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 535848;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13108, '2024-12-18', 185, 265, 265
                    , 264, 265, 264, 253.33
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 265, 66, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-185, sellCostBuyPrice =sellCostBuyPrice-265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-265, sellCostMeanBuyPrice = sellCostMeanBuyPrice-264
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-264
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-253.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-66
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 185, 265, 265
                    , 264, 265, 264, 253.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 66, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-185, sellCostBuyPrice =sellCostBuyPrice-265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-265, sellCostMeanBuyPrice = sellCostMeanBuyPrice-264
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-264
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-253.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-66
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 13:04:28' WHERE storedetailid = '13107';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13108', '1', '1', '0', '146652', 'حذف فاتورة مبيعات', 'sellbillController.php', '4', '5', '2', '2024-12-18 13:04:28','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35272;
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 = 535849;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15935, '2024-12-18', 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-18', 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 = '29', userid = '2', storedetaildate = '2024-12-18 13:04:28' WHERE storedetailid = '15934';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15935', '1', '1', '0', '146652', 'حذف فاتورة مبيعات', 'sellbillController.php', '28', '29', '2', '2024-12-18 13:04:28','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 184.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 184.00
        
                where sellbilldetailid = 535850;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13152, '2024-12-18', 105, 185, 185
                    , 184, 185, 184, 177.6
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-105, sellCostBuyPrice =sellCostBuyPrice-185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-185, sellCostMeanBuyPrice = sellCostMeanBuyPrice-184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-177.6
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 105, 185, 185
                    , 184, 185, 184, 177.6
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-105, sellCostBuyPrice =sellCostBuyPrice-185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-185, sellCostMeanBuyPrice = sellCostMeanBuyPrice-184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-177.6
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 13:04:28' WHERE storedetailid = '13151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13152', '1', '1', '0', '146652', 'حذف فاتورة مبيعات', 'sellbillController.php', '10', '11', '2', '2024-12-18 13:04:28','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 30614;
UPDATE sellbilldetail SET  lastbuyprice = 175.00 , meanbuyprice = 175.00, lastbuyprice_withDiscount = 175.00, meanbuyprice_withDiscount = 175.00
        
                where sellbilldetailid = 535851;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13207, '2024-12-18', 150, 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-150, 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-18', 150, 175, 175
                    , 175, 175, 175, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-150, 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 = '3', userid = '2', storedetaildate = '2024-12-18 13:04:28' WHERE storedetailid = '13206';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13207', '1', '1', '0', '146652', 'حذف فاتورة مبيعات', 'sellbillController.php', '2', '3', '2', '2024-12-18 13:04:28','0','0');
CALL clientInUse(8799,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-500', userid = '2' WHERE clientid = '8799';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8799','167.00','667.00','1','حذف فاتورة مبيعات','146652', '-500', '2024-12-18 13:04:28', '2', 'sellbillController.php', 'حذف فاتورة مبيعات', '667', '0', null, '0', null, null,'', '0','1','1','667','1','2024-11-26 17:08:52','0','0');
UPDATE client SET  inUse = 0 where clientid = 8799;
 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-18', 667, 770, 770
                    , 768, 770, 768, 750.93
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,410, 211, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-667, sellCostBuyPrice =sellCostBuyPrice-770
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-770, sellCostMeanBuyPrice = sellCostMeanBuyPrice-768
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-770, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-768
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-750.93
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-211
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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 (8799, '2024-12-18', 667, 770, 770
                    , 768, 770, 768, 750.93
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 211, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-667, sellCostBuyPrice =sellCostBuyPrice-770
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-770, sellCostMeanBuyPrice = sellCostMeanBuyPrice-768
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-770, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-768
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-750.93
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-211
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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, 667, 770, 770
                    , 768, 770, 768, 750.93, 410, 211)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-667, netSellCostBuyPrice = netSellCostBuyPrice-770
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-770
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-768
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-770
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-768
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-750.93
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-410
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-211;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill delete end - sellbill with id = 146652
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:34:29";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 13:04:29", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:04:29', '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-18 09:34:30";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 13:04:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:04:31', '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-18 09:42:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:12:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:12:11', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762a26c1b364
-- ----------------------------------------------------------------------------------------------------

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-18 12:22:36', '06762a26c1b364', '1', '0.00', '0', '0', '1', '370.00', '370', '370', '0', '1', '2024-12-18 13:12:11', '', '104', '0', 'نقدي', '1', '0', '3', '54', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','370','0','','0','0','370','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','149999', '0', '2024-12-18 13:12:11', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '370', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 12:22:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35306;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1487', '149999', '14', '15909', '1', '370', '370', '0', '', '1', '2024-12-18 13:12:11', '15909', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35306-1,','1','1','0','0','370','370','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 = 320, lastbuyprice_withDiscountAndTax = 320
                where sellbilldetailid = 547954;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15909, '2024-12-18', 370, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, 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+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 370, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, 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 = '25', userid = '104', storedetaildate = '2024-12-18 13:12:11' WHERE storedetailid = '15908';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15909', '1', '1', '1', '149999', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '104', '2024-12-18 13:12:11','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '11255',  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 ('10885','370', '0', '1', 'اضافة فاتورة مبيعات', '149999', '11255', '2024-12-18 13:12:11', '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-18', 370, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, 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;
 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-18', 370, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 370, 320, 320
                    , 320, 320, 320, 320, 320, 320)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+370, netSellCostBuyPrice = netSellCostBuyPrice+320
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+320
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+320
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+320
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+320
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+320
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+320
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+320;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762a26c1b364 and sellbillId = 149999 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:42:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:12:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:12:12', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:43:34";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 13:13:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:13:34', '2', '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-18 09:45:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:15:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:15:09', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762ae0ca57d2
-- ----------------------------------------------------------------------------------------------------

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-18 13:12:12', '06762ae0ca57d2', '1', '0.00', '0', '0', '1', '1550.00', '1550', '1550', '0', '1', '2024-12-18 13:15:09', '', '104', '0', 'نقدي', '1', '0', '3', '92', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','1550','0','','0','0','1550','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150000', '0', '2024-12-18 13:15:09', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1550', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 13:12:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35575;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1489', '150000', '14', '15910', '1', '300', '300', '0', '', '1', '2024-12-18 13:15:09', '15910', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35575-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 = 547955;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15910, '2024-12-18', 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-18', 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 = '9', userid = '104', storedetaildate = '2024-12-18 13:15:09' WHERE storedetailid = '15909';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15910', '1', '1', '1', '150000', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-18 13:15:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35925;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1578', '150000', '14', '16199', '1', '580', '580', '0', '', '1', '2024-12-18 13:15:09', '16199', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35925-1,','1','1','0','0','580','580','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 = 547956;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16199, '2024-12-18', 580, 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+580, 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-18', 580, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, 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 = '6', userid = '104', storedetaildate = '2024-12-18 13:15:09' WHERE storedetailid = '16198';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16199', '1', '1', '1', '150000', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-18 13:15:09','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', '150000', '14', '16257', '1', '270', '270', '0', '', '1', '2024-12-18 13:15:09', '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 = 547957;
 INSERT INTO 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-18', 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-18', 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 = '13', userid = '104', storedetaildate = '2024-12-18 13:15:09' WHERE storedetailid = '16256';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16257', '1', '1', '1', '150000', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '104', '2024-12-18 13:15:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35959;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3272', '150000', '1', '15763', '1', '400', '400', '0', '', '1', '2024-12-18 13:15:09', '15763', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35959-1,','1','1','0','0','400','400','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 = 547958;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15763, '2024-12-18', 400, 340, 340
                    , 340, 340, 340, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , 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-18', 400, 340, 340
                    , 340, 340, 340, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , 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 = '12', userid = '104', storedetaildate = '2024-12-18 13:15:09' WHERE storedetailid = '15762';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15763', '1', '1', '1', '150000', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '104', '2024-12-18 13:15:09','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '12805',  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 ('11255','1550', '0', '1', 'اضافة فاتورة مبيعات', '150000', '12805', '2024-12-18 13:15:09', '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-18', 1550, 1265, 1265
                    , 1265, 1265, 1265, 1260
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1265, 1265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1550, sellCostBuyPrice =sellCostBuyPrice+1265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1550, 1265, 1265
                    , 1265, 1265, 1265, 1260
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1265, 1265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1550, sellCostBuyPrice =sellCostBuyPrice+1265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1265
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1265
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1550, 1265, 1265
                    , 1265, 1265, 1265, 1260, 1265, 1265)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1550, netSellCostBuyPrice = netSellCostBuyPrice+1265
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1265
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1265
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1265
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1265
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1260
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1265
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1265;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762ae0ca57d2 and sellbillId = 150000 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:45:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:15:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:15:10', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:47:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:17:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 13:17:40', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:47:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:17:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:17:51', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:48:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:18:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:18:32', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762af6011223
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4574,@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-18 13:17:52', '06762af6011223', '4574', '103180.00', '103820', '0', '1', '640.00', '640', '0', '640', '1', '2024-12-18 13:18:32', '', '104', '0', 'مكتب روما يحيي', '1', '1', '3', '72', 'مكتب روما يحيي', '2' ,'0','','','','','-1','0','0','0','0','0','640','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '103820', userid = '104' WHERE clientid = '4574';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4574','103180.00','640','0','اضافة فاتورة مبيعات','150001', '103820', '2024-12-18 13:18:32', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '640', '0', null, '0', null, null,'', '0','1','1','640','1','2024-12-18 13:17:52','0','0');
UPDATE client SET  inUse = 0 where clientid = 4574;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36177;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07279', '150001', '5', '16403', '2', '320', '640', '0', '', '1', '2024-12-18 13:18:32', '16403', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36177-2,','1','1','0','0','320','640','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 = 133, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 547959;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16403, '2024-12-18', 640, 530, 530
                    , 530, 530, 530, 530
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 530, 266, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+640, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+530
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+530
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+266
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 640, 530, 530
                    , 530, 530, 530, 530
                    , 0, 0, 0, 0
                    , 0, 0, 0, 530, 266, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+640, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+530
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+530
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+266
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 13:18:32' WHERE storedetailid = '16402';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16403', '1', '2', '1', '150001', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '11', '104', '2024-12-18 13:18:32','0','0');
UPDATE client SET  delegateid = 72 where clientid = 4574;
 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-18', 640, 530, 530
                    , 530, 530, 530, 530
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,530, 266, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+640, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+530
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+530
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+266
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (4574, '2024-12-18', 640, 530, 530
                    , 530, 530, 530, 530
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,530, 266, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+640, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+530
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+530
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+266
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 640, 530, 530
                    , 530, 530, 530, 530, 530, 266)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+640, netSellCostBuyPrice = netSellCostBuyPrice+530
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+530
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+530
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+530
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+530
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+530
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+530
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+266;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762af6011223 and sellbillId = 150001 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:48:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:18:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:18:33', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:49:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:19:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:19:02', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:52:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:22:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:22:31', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762afa695d31
-- ----------------------------------------------------------------------------------------------------

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-18 13:19:02', '06762afa695d31', '1', '0.00', '0', '0', '1', '100.00', '100', '100', '0', '1', '2024-12-18 13:22:31', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','100','0','','0','0','100','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150002', '0', '2024-12-18 13:22:31', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '100', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 13:19:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31333;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06200', '150002', '5', '14102', '1', '100', '100', '0', '', '1', '2024-12-18 13:22:31', '14102', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31333-1,','1','1','0','0','100','100','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 = 547960;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14102, '2024-12-18', 100, 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+100, 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-18', 100, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, 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 = '104', storedetaildate = '2024-12-18 13:22:31' WHERE storedetailid = '14101';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14102', '1', '1', '1', '150002', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-18 13:22:31','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '12905',  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 ('12805','100', '0', '1', 'اضافة فاتورة مبيعات', '150002', '12905', '2024-12-18 13:22:31', '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-18', 100, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, 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;
 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-18', 100, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 100, 250, 250
                    , 250, 250, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+100, netSellCostBuyPrice = netSellCostBuyPrice+250
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+250
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+250
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+250
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+250
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+250
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762afa695d31 and sellbillId = 150002 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247272
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1015,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '20' , clientdate = '2024-12-18 13:22:44', userid = '2' WHERE clientid = '1015';
UPDATE client SET  inUse = 0 where clientid = 1015;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1015','687.00','667','1','ايصال تحصيل (( قبض من عميل ))','247272', '20', '2024-12-18 12:48:42', '2', 'clientPayedDeptController.php', '   ', '667', '0', null, '0', null, null,'', '-1','1','1','667','1','','3498','0');
UPDATE save SET  savecurrentvalue = '197840.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('197173.50','667', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247282', '197840.5', '2024-12-18 13:22: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 ('هبة السيد يوسف k105', 'هبة السيد يوسف k105', 'هبة السيد يوسف k105', 'هبة السيد يوسف k105', '58', '0', '20.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-18 13:22:44');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '667', '667', '2024-12-18', '2', '0', '0', '2024-12-18 13:22:44','اضافة ايصال سداد للعميل هبة السيد يوسف k105','1','0','0','0','247282','clientPayedDeptController.php?do=show&id=247282');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122143', '-1', '667', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '667', 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 ('122143', '12548', '667', '','0');
UPDATE accountstree SET name = 'هبة السيد يوسف k105', customName = 'هبة السيد يوسف k105', customNameEn = 'هبة السيد يوسف k105', nameEn = 'هبة السيد يوسف k105', parent = '58', accountNature = '0', theValue = '-647', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 13:22:44' WHERE id = '12548';
UPDATE clientdebtchange SET clientid = '1015', clientdebtchangebefore = '687.000', clientdebtchangeamount = '667.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247272', clientdebtchangeafter = '20.000', clientdebtchangedate = '2024-12-18 12:48:42', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '667.00',discount='', reciptid='0', dailyentryid = '122143',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='667',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247282';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247272 -clientdebtchangeId = 247282
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247283
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7954,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 13:23:04', userid = '2' WHERE clientid = '7954';
UPDATE client SET  inUse = 0 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','1175.00','1175','1','ايصال تحصيل (( قبض من عميل ))','247283', '0', '2024-12-18 13:22:44', '2', 'clientPayedDeptController.php', '   ', '1175', '0', null, '0', null, null,'', '-1','1','1','1175','1','','3499','0');
UPDATE save SET  savecurrentvalue = '199015.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('197840.50','1175', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247283', '199015.5', '2024-12-18 13:23:04', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1175', '1175', '2024-12-18', '2', '0', '0', '2024-12-18 13:23:05','اضافة ايصال سداد للعميل ياسمين نصار W229','1','0','0','0','247283','clientPayedDeptController.php?do=show&id=247283');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122144', '-1', '1175', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1175', 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 ('122144', '-1', '1175', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1175', 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 = '7954', clientdebtchangebefore = '1175.000', clientdebtchangeamount = '1175.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247283', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 13:22:44', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1175.00',discount='', reciptid='0', dailyentryid = '122144',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1175',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247283';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:53:05";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 13:23:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 13:23: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-18 09:53:24";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 13:23:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 13:23:24', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247284
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9961,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 13:23:24', userid = '2' WHERE clientid = '9961';
UPDATE client SET  inUse = 0 where clientid = 9961;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9961','2197.00','2197','1','ايصال تحصيل (( قبض من عميل ))','247284', '0', '2024-12-18 13:23:05', '2', 'clientPayedDeptController.php', '   ', '2197', '0', null, '0', null, null,'', '-1','1','1','2197','1','','3500','0');
UPDATE save SET  savecurrentvalue = '201212.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('199015.50','2197', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247284', '201212.5', '2024-12-18 13:23:24', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '2197', '2197', '2024-12-18', '2', '0', '0', '2024-12-18 13:23:24','اضافة ايصال سداد للعميل سارة رجب حسن 12','1','0','0','0','247284','clientPayedDeptController.php?do=show&id=247284');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122145', '-1', '2197', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '2197', 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 ('122145', '-1', '2197', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-2197', 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 = '9961', clientdebtchangebefore = '2197.000', clientdebtchangeamount = '2197.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247284', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 13:23:05', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '2197.00',discount='', reciptid='0', dailyentryid = '122145',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='2197',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247284';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:53:25";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 13:23:25", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 13:23:25', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:54:17";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 13:24:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 13:24:17', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247285
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5687,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '37' , clientdate = '2024-12-18 13:24:18', userid = '2' WHERE clientid = '5687';
UPDATE client SET  inUse = 0 where clientid = 5687;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5687','3737.00','3700','1','ايصال تحصيل (( قبض من عميل ))','247285', '37', '2024-12-18 13:23:25', '2', 'clientPayedDeptController.php', '   ', '3700', '0', null, '0', null, null,'', '-1','1','1','3700','1','','3501','0');
UPDATE save SET  savecurrentvalue = '1975112',  userid = '2' WHERE saveid = '3';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('1971412.00','3700', '0', '3', 'ايصال تحصيل (( قبض من عميل ))', '247285', '1975112', '2024-12-18 13:24:18', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '3700', '3700', '2024-12-18', '2', '0', '0', '2024-12-18 13:24:18','اضافة ايصال سداد للعميل مريم عبد المسيح X192','1','0','0','0','247285','clientPayedDeptController.php?do=show&id=247285');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122146', '-1', '3700', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '3700', 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 ('122146', '-1', '3700', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-3700', 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 = '5687', clientdebtchangebefore = '3737.000', clientdebtchangeamount = '3700.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247285', clientdebtchangeafter = '37.000', clientdebtchangedate = '2024-12-18 13:23:25', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '3700.00',discount='', reciptid='0', dailyentryid = '122146',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='3700',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247285';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762ae5e4f34a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9016,@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-18 13:13:34', '06762ae5e4f34a', '9016', '0.00', '960', '0', '1', '960.00', '960', '0', '960', '1', '2024-12-18 13:27:19', '', '2', '0', 'لميس فرج P504', '2', '1', '3', '82', 'لميس فرج P504', '4' ,'0','','','','','-1','0','0','0','0','0','960','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '960', userid = '2' WHERE clientid = '9016';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9016','0.00','960','0','اضافة فاتورة مبيعات','150003', '960', '2024-12-18 13:27:19', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات', '960', '0', null, '0', null, null,'', '0','1','1','960','1','2024-12-18 13:13:34','0','0');
UPDATE client SET  inUse = 0 where clientid = 9016;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34790;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1446', '150003', '14', '15798', '1', '320', '320', '0', '', '1', '2024-12-18 13:27:19', '15798', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34790-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 = 547961;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15798, '2024-12-18', 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-18', 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 = '10', userid = '2', storedetaildate = '2024-12-18 13:27:19' WHERE storedetailid = '15797';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15798', '1', '1', '1', '150003', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '2', '2024-12-18 13:27:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35722;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1379', '150003', '14', '15622', '1', '610', '610', '0', '', '1', '2024-12-18 13:27:19', '15622', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35722-1,','1','1','0','0','610','610','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 501.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 501.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 509, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 547962;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15622, '2024-12-18', 610, 500, 500
                    , 501, 500, 501, 425.29
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 509, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+501
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+501
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+509
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 610, 500, 500
                    , 501, 500, 501, 425.29
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 509, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+501
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+501
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+509
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 13:27:19' WHERE storedetailid = '15621';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15622', '1', '1', '1', '150003', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '2', '2024-12-18 13:27:19','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', '150003', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 13:27:19', '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', '150003', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-18 13:27:19', '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 = 82 where clientid = 9016;
 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-18', 960, 780, 780
                    , 781, 780, 781, 705.29
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,780, 789, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+960, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+781
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+781
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+705.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+780
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+789
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (9016, '2024-12-18', 960, 780, 780
                    , 781, 780, 781, 705.29
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,780, 789, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+960, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+781
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+781
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+705.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+780
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+789
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 960, 780, 780
                    , 781, 780, 781, 705.29, 780, 789)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+960, netSellCostBuyPrice = netSellCostBuyPrice+780
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+780
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+781
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+780
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+781
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+705.29
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+780
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+789;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762ae5e4f34a and sellbillId = 150003 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:57:20";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 13:27:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:27:20', '2', '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-18 09:57:45";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 13:27:45", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:27:45', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762abe52e301
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10739,@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-18 13:03:01', '06762abe52e301', '10739', '3955.00', '4420', '0', '1', '465.00', '465', '0', '465', '1', '2024-12-18 13:27:45', '', '75', '0', 'ندا طارق 100', '2', '1', '3', '83', 'ندا طارق 100', '2' ,'0','','','','','-1','0','0','0','0','0','465','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '4420', userid = '75' WHERE clientid = '10739';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10739','3955.00','465','0','اضافة فاتورة مبيعات','150004', '4420', '2024-12-18 13:27:45', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '465', '0', null, '0', null, null,'', '0','1','1','465','1','2024-12-18 13:03:01','0','0');
UPDATE client SET  inUse = 0 where clientid = 10739;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34623;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','56910', '150004', '5', '15629', '1', '460', '460', '0', '', '1', '2024-12-18 13:27:46', '15629', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34623-1,','1','1','0','0','460','460','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 = 547965;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15629, '2024-12-18', 460, 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+460, 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-18', 460, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, 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 = '1', userid = '75', storedetaildate = '2024-12-18 13:27:46' WHERE storedetailid = '15628';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15629', '1', '1', '1', '150004', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-18 13:27: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', '150004', '17', '10291', '1', '5', '5', '0', '', '1', '2024-12-18 13:27:46', '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 = 83 where clientid = 10739;
 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-18', 465, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+465, 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 (10739, '2024-12-18', 465, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+465, 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, 465, 400, 400
                    , 400, 400, 400, 400, 400, 400)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+465, 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 06762abe52e301 and sellbillId = 150004 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:57:46";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 13:27:46", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:27:46', '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-18 09:58:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:28:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:28:02', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762b1442ac7f
-- ----------------------------------------------------------------------------------------------------

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-18 13:25:56', '06762b1442ac7f', '1', '0.00', '0', '0', '1', '400.00', '400', '400', '0', '1', '2024-12-18 13:28:02', '', '104', '0', 'نقدي', '1', '0', '3', '26', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150005', '0', '2024-12-18 13:28:02', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '400', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 13:25:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35125;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1377', '150005', '14', '15585', '1', '400', '400', '0', '', '1', '2024-12-18 13:28:02', '15585', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35125-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 302.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 302.00
        , lastbuyprice_withTax = 310, meanbuyprice_withTax = 275, lastbuyprice_withDiscountAndTax = 310
                where sellbilldetailid = 547967;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15585, '2024-12-18', 400, 310, 310
                    , 302, 310, 302, 303.04
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 310, 275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+303.04
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 400, 310, 310
                    , 302, 310, 302, 303.04
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+303.04
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 13:28:02' WHERE storedetailid = '15584';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15585', '1', '1', '1', '150005', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-18 13:28:02','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '13305',  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 ('12905','400', '0', '1', 'اضافة فاتورة مبيعات', '150005', '13305', '2024-12-18 13:28:02', '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-18', 400, 310, 310
                    , 302, 310, 302, 303.04
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,310, 275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+303.04
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 400, 310, 310
                    , 302, 310, 302, 303.04
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,310, 275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+303.04
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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
                    , 302, 310, 302, 303.04, 310, 275)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+400, netSellCostBuyPrice = netSellCostBuyPrice+310
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+310
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+302
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+310
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+302
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+303.04
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+310
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+275;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762b1442ac7f and sellbillId = 150005 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 09:58:03";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:28:03", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:28:03', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:00:44";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 13:30:44", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:30: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 06762b1b2c1779
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4923,@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-18 13:27:46', '06762b1b2c1779', '4923', '0.00', '187', '0', '1', '187.00', '187', '0', '187', '1', '2024-12-18 13:30:45', '', '75', '0', 'ايمي فاشون I66', '2', '1', '3', '81', 'ايمي فاشون I66', '3' ,'0','','','','','-1','0','0','0','0','0','187','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '187', userid = '75' WHERE clientid = '4923';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4923','0.00','187','0','اضافة فاتورة مبيعات','150006', '187', '2024-12-18 13:30:45', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '187', '0', null, '0', null, null,'', '0','1','1','187','1','2024-12-18 13:27:46','0','0');
UPDATE client SET  inUse = 0 where clientid = 4923;
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', '150006', '1', '16265', '1', '165', '165', '0', '', '1', '2024-12-18 13:30:45', '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 = 547968;
 INSERT INTO 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-18', 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-18', 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 = '5', userid = '75', storedetaildate = '2024-12-18 13:30:45' WHERE storedetailid = '16264';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16265', '1', '1', '1', '150006', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-18 13:30:45','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', '150006', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 13:30:45', '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', '150006', '17', '10291', '1', '2', '2', '0', '', '1', '2024-12-18 13:30:45', '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 = 81 where clientid = 4923;
 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-18', 187, 115, 115
                    , 115, 115, 115, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,115, 115, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+187, 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 (4923, '2024-12-18', 187, 115, 115
                    , 115, 115, 115, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,115, 115, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+187, 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, 187, 115, 115
                    , 115, 115, 115, 115, 115, 115)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+187, 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 06762b1b2c1779 and sellbillId = 150006 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:00:45";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 13:30:45", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:30: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-18 10:10:18";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 13:40:18", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:40:18', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762b265d6ceb
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(139,@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-18 13:30:45', '06762b265d6ceb', '139', '58.00', '2755', '0', '1', '2697.00', '2697', '0', '2697', '1', '2024-12-18 13:40:18', '', '75', '0', 'ناهد احمد S144', '2', '1', '3', '83', 'ناهد احمد S144', '8' ,'0','','','','','-1','0','0','0','0','0','2697','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '2755', userid = '75' WHERE clientid = '139';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('139','58.00','2697','0','اضافة فاتورة مبيعات','150007', '2755', '2024-12-18 13:40:18', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2697', '0', null, '0', null, null,'', '0','1','1','2697','1','2024-12-18 13:30:45','0','0');
UPDATE client SET  inUse = 0 where clientid = 139;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36343;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06603', '150007', '5', '15038', '1', '290', '290', '0', '', '1', '2024-12-18 13:40:18', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36343-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 = 547971;
 INSERT INTO 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-18', 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-18', 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 = '64', userid = '75', storedetaildate = '2024-12-18 13:40:18' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '1', '1', '150007', 'اضافة فاتورة مبيعات', 'sellbillController.php', '65', '64', '75', '2024-12-18 13:40:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35723;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1461', '150007', '14', '15848', '1', '620', '620', '0', '', '1', '2024-12-18 13:40:18', '15848', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35723-1,','1','1','0','0','620','620','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 = 546, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 547972;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15848, '2024-12-18', 620, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 546, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+546
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 620, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 546, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+546
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 13:40:19' WHERE storedetailid = '15847';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15848', '1', '1', '1', '150007', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-18 13:40:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36376;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07299', '150007', '5', '16443', '2', '270', '540', '0', '', '1', '2024-12-18 13:40:19', '16443', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36376-2,','1','1','0','0','270','540','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 = 547973;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16443, '2024-12-18', 540, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, 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+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-18', 540, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, 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 = '13', userid = '75', storedetaildate = '2024-12-18 13:40:19' WHERE storedetailid = '16442';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16443', '1', '2', '1', '150007', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '13', '75', '2024-12-18 13:40:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36091;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07261', '150007', '5', '16367', '1', '580', '580', '0', '', '1', '2024-12-18 13:40:19', '16367', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36091-1,','1','1','0','0','580','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 496.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 496.00
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 499, lastbuyprice_withDiscountAndTax = 495
                where sellbilldetailid = 547974;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16367, '2024-12-18', 580, 495, 495
                    , 496, 495, 496, 497.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 495, 499, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+496
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+496
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+497.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+499
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 580, 495, 495
                    , 496, 495, 496, 497.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 499, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+496
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+496
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+497.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+499
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 13:40:19' WHERE storedetailid = '16366';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16367', '1', '1', '1', '150007', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-18 13:40:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36101;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07257', '150007', '5', '16373', '1', '620', '620', '0', '', '1', '2024-12-18 13:40:19', '16373', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36101-1,','1','1','0','0','620','620','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 = 550, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 547975;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16373, '2024-12-18', 620, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 550, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 620, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 13:40:19' WHERE storedetailid = '16372';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16373', '1', '1', '1', '150007', 'اضافة فاتورة مبيعات', 'sellbillController.php', '38', '37', '75', '2024-12-18 13:40:19','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', '150007', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 13:40:19', '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', '150007', '17', '10291', '1', '27', '27', '0', '', '1', '2024-12-18 13:40:19', '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 = 83 where clientid = 139;
 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-18', 2697, 2210, 2210
                    , 2212, 2210, 2212, 2223.45
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2210, 2262, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2697, sellCostBuyPrice =sellCostBuyPrice+2210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2212
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2212
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2223.45
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2262
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (139, '2024-12-18', 2697, 2210, 2210
                    , 2212, 2210, 2212, 2223.45
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2210, 2262, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2697, sellCostBuyPrice =sellCostBuyPrice+2210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2212
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2212
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2223.45
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2262
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 2697, 2210, 2210
                    , 2212, 2210, 2212, 2223.45, 2210, 2262)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2697, netSellCostBuyPrice = netSellCostBuyPrice+2210
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2212
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2210
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2212
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2223.45
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2210
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2262;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762b265d6ceb and sellbillId = 150007 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:10:19";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 13:40:19", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:40: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-18 10:16:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:46:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:46:02', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=4');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:16:10";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 13:46:10", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:46: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 06762b4a3e99b5
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3988,@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-18 13:40:19', '06762b4a3e99b5', '3988', '35.00', '540', '0', '1', '505.00', '505', '0', '505', '1', '2024-12-18 13:46:10', '', '75', '0', 'هايدي محمد الشرقية f211', '2', '1', '3', '86', 'هايدي محمد الشرقية f211', '3' ,'0','','','','','-1','0','0','0','0','0','505','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '540', userid = '75' WHERE clientid = '3988';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3988','35.00','505','0','اضافة فاتورة مبيعات','150008', '540', '2024-12-18 13:46:10', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '505', '0', null, '0', null, null,'', '0','1','1','505','1','2024-12-18 13:40:19','0','0');
UPDATE client SET  inUse = 0 where clientid = 3988;
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', '150008', '5', '16244', '1', '480', '480', '0', '', '1', '2024-12-18 13:46:10', '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 = 547978;
 INSERT INTO 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-18', 480, 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+480, 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-18', 480, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, 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 = '75', storedetaildate = '2024-12-18 13:46:10' WHERE storedetailid = '16243';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16244', '1', '1', '1', '150008', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-18 13:46: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', '150008', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 13:46: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', '150008', '17', '10291', '1', '5', '5', '0', '', '1', '2024-12-18 13:46:10', '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 = 86 where clientid = 3988;
 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-18', 505, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+505, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (3988, '2024-12-18', 505, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+505, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 505, 440, 440
                    , 440, 440, 440, 440, 440, 440)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+505, netSellCostBuyPrice = netSellCostBuyPrice+440
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+440
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+440
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+440
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+440
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+440
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+440
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+440;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762b4a3e99b5 and sellbillId = 150008 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:16:11";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 13:46:11", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:46: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-18 10:16:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:46:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 13:46:22', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:17:07";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 13:47:07", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:47:07', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762a37b1ac7e
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(235,@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-18 12:27:07', '06762a37b1ac7e', '235', '54.00', '761', '0', '1', '707.00', '707', '0', '707', '1', '2024-12-18 13:47:07', '', '75', '0', 'لمياء حداد i71', '2', '1', '3', '81', 'لمياء حداد i71', '5' ,'0','','','','','-1','0','0','0','0','0','707','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '761', userid = '75' 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','54.00','707','0','اضافة فاتورة مبيعات','150009', '761', '2024-12-18 13:47:07', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '707', '0', null, '0', null, null,'', '0','1','1','707','1','2024-12-18 12:27:07','0','0');
UPDATE client SET  inUse = 0 where clientid = 235;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34383;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','88248', '150009', '5', '15550', '1', '235', '235', '0', '', '1', '2024-12-18 13:47:08', '15550', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34383-1,','1','1','0','0','235','235','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 = 547981;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15550, '2024-12-18', 235, 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+235, 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-18', 235, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, 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 = '2', userid = '75', storedetaildate = '2024-12-18 13:47:08' WHERE storedetailid = '15549';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15550', '1', '1', '1', '150009', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-18 13:47:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34718;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06856', '150009', '5', '15631', '1', '245', '245', '0', '', '1', '2024-12-18 13:47:08', '15631', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34718-1,','1','1','0','0','245','245','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 239.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 239.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 238, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 547982;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15631, '2024-12-18', 245, 240, 240
                    , 239, 240, 239, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+245, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+239
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , 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-18', 245, 240, 240
                    , 239, 240, 239, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+245, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+239
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , 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 = '6', userid = '75', storedetaildate = '2024-12-18 13:47:08' WHERE storedetailid = '15630';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15631', '1', '1', '1', '150009', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-18 13:47: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 ('200','عرض 200', '150009', '18', '10353', '1', '200', '200', '0', '', '1', '2024-12-18 13:47:08', '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 = 547983;
 INSERT INTO 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-18', 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-18', 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 = '-25', userid = '75', storedetaildate = '2024-12-18 13:47:08' WHERE storedetailid = '10352';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10353', '1', '1', '1', '150009', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-24', '-25', '75', '2024-12-18 13:47: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 ('20','50235', '150009', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 13:47:08', '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', '150009', '17', '10291', '1', '7', '7', '0', '', '1', '2024-12-18 13:47:08', '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 = 81 where clientid = 235;
 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-18', 707, 680, 680
                    , 679, 680, 679, 477.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+707, sellCostBuyPrice =sellCostBuyPrice+680
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+680, sellCostMeanBuyPrice = sellCostMeanBuyPrice+679
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+680, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+679
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+477.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , 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 (235, '2024-12-18', 707, 680, 680
                    , 679, 680, 679, 477.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+707, sellCostBuyPrice =sellCostBuyPrice+680
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+680, sellCostMeanBuyPrice = sellCostMeanBuyPrice+679
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+680, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+679
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+477.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , 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, 707, 680, 680
                    , 679, 680, 679, 477.5, 240, 238)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+707, netSellCostBuyPrice = netSellCostBuyPrice+680
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+680
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+679
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+680
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+679
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+477.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+240
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+238;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762a37b1ac7e and sellbillId = 150009 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:17:08";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 13:47:08", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:47:08', '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-18 10:17:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:47:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:47:29', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762b5fab48d9
-- ----------------------------------------------------------------------------------------------------

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-18 13:46:02', '06762b5fab48d9', '1', '0.00', '0', '0', '1', '-20.00', '-20', '-20', '0', '1', '2024-12-18 13:47:29', '', '104', '0', 'نقدي', '1', '0', '4', '0', '230', '250', 'نقدي', '1', '1', '0', '', '', '','','-1','0','0','0','','0','-20','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','1','اضافة فاتورة مبيعات ومردودات','114', '0', '2024-12-18 13:47:29', '104', 'sellbillandruternController.php', 'اضافة فاتورة مبيعات ومردودات', '20', '0', null, '0', null, null,'', '0','1','1','-0','1','2024-12-18 13:46:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33254;
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 ('320','06537', '114', '5', '14964', '1', '230', '230.00', '0', '', '0', '2024-12-18 13:47:30', '0', '14964', '0.00', '-1', '1','0','','','0','0','0','0','0','0','33254-1,','1','1','','0','0','230','230','0','','','0');
UPDATE sellandruternbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
        
                where sellbilldetailid = 298;
 INSERT INTO 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-18', 230, 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+230, 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-18', 230, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, 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 = '2', userid = '104', storedetaildate = '2024-12-18 13:47:30' WHERE storedetailid = '14963';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14964', '1', '1', '1', '114', 'فاتوره مبيعات ومردودات', 'sellbillandruternController.php', '3', '2', '104', '2024-12-18 13:47:30','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 ('200.00','07262', '114', '5', '16384', '1', '250', '250', '0', '', '0', '2024-12-18 13:47:30', '1', '16384', '0.00', '-1', '1','0','','','0','0','0','0','0','0','','1','1','','0','0','250','250','0','','','0');
UPDATE sellandruternbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 200.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 200.00
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 100, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 299;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16384, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 200, 200, 200
                    , 200, 200, 200, 0, 1, 0, 0, 200, 100)
                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+250, returnSellCostBuyPrice = returnSellCostBuyPrice+200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+200
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+200
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+200
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+100
                        , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 200, 200, 200
                    , 200, 200, 200, 0, 0, 200, 100)
                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+250, returnSellCostBuyPrice = returnSellCostBuyPrice+200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+200
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+200
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+200
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+100;
UPDATE storedetail SET  productquantity = '13', userid = '104', storedetaildate = '2024-12-18 13:47:30' WHERE storedetailid = '16383';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16384', '1', '1', '0', '114', 'اضافة فاتورة مردودات مبيعات', 'sellbillandruternController.php', '12', '13', '104', '2024-12-18 13:47:30','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '13285',  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 ('13305','20', '1', '1', 'اضافة فاتورة مبيعات ومردودات', '114', '13285', '2024-12-18 13:47:30', '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-18', 230, 320, 320
                    , 320, 320, 320, 320
                    , 250, 200, 200, 200
                    , 200, 200, 200 ,0, 0, 200, 100)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, 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+250, returnSellCostBuyPrice = returnSellCostBuyPrice+200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+200
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+200
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+200
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+100;
 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-18', 230, 320, 320
                    , 320, 320, 320, 320
                    , 250, 200, 200, 200
                    , 200, 200, 200 ,0, 0, 200, 100)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, 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+250, returnSellCostBuyPrice = returnSellCostBuyPrice+200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+200
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+200
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+200
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+100;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -20, 120, 120
                    , 120, 120, 120, 120, -200, -100)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-20, netSellCostBuyPrice = netSellCostBuyPrice+120
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+120
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+120
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+120
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+120
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+120
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-200
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-100;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762b5fab48d9 and sellbillId = 114 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:17:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:47:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-18 13:47:30', '104', 'editprint', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=editprint&id=114');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:19:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:49:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 13:49:19', '104', 'add', '192.168.1.13', '', '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-18', '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 = '13235',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('13285.00','50', '1', '1', 'إضافة مصروف', '25820', '13235', '2024-12-18 13:49:19', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'محمد عبدة', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-18', 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 = '25820';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:19:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:49:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 13:49:20', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:19:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:49:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 13:49:21', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:19:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:49:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 13:49:23', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:19:35";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:49:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 13:49:35', '104', 'add', '192.168.1.13', '', '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-18', '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 = '13185',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('13235.00','50', '1', '1', 'إضافة مصروف', '25821', '13185', '2024-12-18 13:49:35', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كريم هادي', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-18', 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 = '25821';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:19:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:49:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 13:49:36', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:19:37";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:49:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 13:49:37', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:25:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:55:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:55:17', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:26:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 13:56:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 13:56:15', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762b8258de70
-- ----------------------------------------------------------------------------------------------------

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-18 13:55:17', '06762b8258de70', '1', '0.00', '0', '0', '1', '490.00', '490', '490', '0', '1', '2024-12-18 13:56:15', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','490','0','','0','0','490','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150010', '0', '2024-12-18 13:56:15', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '490', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 13:55:17','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', '150010', '5', '16378', '1', '220', '220', '0', '', '1', '2024-12-18 13:56:15', '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 = 547986;
 INSERT INTO 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-18', 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-18', 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 = '11', userid = '104', storedetaildate = '2024-12-18 13:56:15' WHERE storedetailid = '16377';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16378', '1', '1', '1', '150010', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-18 13:56:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36323;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07289', '150010', '5', '16419', '1', '270', '270', '0', '', '1', '2024-12-18 13:56:15', '16419', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36323-1,','1','1','0','0','270','270','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 = 547987;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16419, '2024-12-18', 270, 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+270, 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-18', 270, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, 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 = '11', userid = '104', storedetaildate = '2024-12-18 13:56:15' WHERE storedetailid = '16418';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16419', '1', '1', '1', '150010', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-18 13:56:15','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '13675',  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 ('13185','490', '0', '1', 'اضافة فاتورة مبيعات', '150010', '13675', '2024-12-18 13:56:15', '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-18', 490, 370, 370
                    , 370, 370, 370, 370
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,370, 370, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, 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;
 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-18', 490, 370, 370
                    , 370, 370, 370, 370
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,370, 370, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 490, 370, 370
                    , 370, 370, 370, 370, 370, 370)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+490, netSellCostBuyPrice = netSellCostBuyPrice+370
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+370
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+370
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+370
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+370
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+370
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+370
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+370;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762b8258de70 and sellbillId = 150010 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762b86039a4d
-- ----------------------------------------------------------------------------------------------------

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-18 13:56:16', '06762b86039a4d', '1', '0.00', '0', '0', '1', '280.00', '280', '280', '0', '1', '2024-12-18 14:00:54', '', '104', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150011', '0', '2024-12-18 14:00:54', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '280', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 13:56:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35991;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07258', '150011', '5', '16336', '1', '280', '280', '0', '', '1', '2024-12-18 14:00:54', '16336', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35991-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 = 547988;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16336, '2024-12-18', 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-18', 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 = '11', userid = '104', storedetaildate = '2024-12-18 14:00:54' WHERE storedetailid = '16335';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16336', '1', '1', '1', '150011', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-18 14:00:54','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '13955',  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 ('13675','280', '0', '1', 'اضافة فاتورة مبيعات', '150011', '13955', '2024-12-18 14:00:55', '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-18', 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-18', 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 06762b86039a4d and sellbillId = 150011 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:30:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:00:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:00:55', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:43:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:13:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:13:54', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762b977a2c2f
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10298,@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-18 14:00:55', '06762b977a2c2f', '10298', '0.00', '1232', '0', '1', '1232.00', '1232', '0', '1232', '1', '2024-12-18 14:13:54', '', '104', '0', 'امنية عبد الهادي 73', '1', '1', '3', '4', 'امنية عبد الهادي 73', '3' ,'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-18','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1232', userid = '104' WHERE clientid = '10298';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10298','0.00','1232','0','اضافة فاتورة مبيعات','150012', '1232', '2024-12-18 14:13:54', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1232', '0', null, '0', null, null,'', '0','1','1','1232','1','2024-12-18 14:00:55','0','0');
UPDATE client SET  inUse = 0 where clientid = 10298;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35709;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07113', '150012', '5', '16201', '1', '570', '570', '0', '', '1', '2024-12-18 14:13:54', '16201', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35709-1,','1','1','0','0','570','570','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail 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 sellbilldetailid = 547989;
 INSERT INTO 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-18', 570, 500, 500
                    , 497, 500, 497, 498.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 497, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+570, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+497
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+497
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+498.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+497
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 570, 500, 500
                    , 497, 500, 497, 498.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 497, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+570, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+497
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+497
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+498.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+497
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 14:13:54' WHERE storedetailid = '16200';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16201', '1', '1', '1', '150012', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-18 14:13:54','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', '150012', '5', '16254', '1', '650', '650', '0', '', '1', '2024-12-18 14:13:54', '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 = 547990;
 INSERT INTO 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-18', 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-18', 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 = '14', userid = '104', storedetaildate = '2024-12-18 14:13:54' WHERE storedetailid = '16253';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16254', '1', '1', '1', '150012', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-18 14:13: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 ('0','10291', '150012', '17', '10291', '1', '12', '12', '0', '', '1', '2024-12-18 14:13:54', '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 = 4 where clientid = 10298;
 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-18', 1232, 995, 995
                    , 992, 995, 992, 993.33
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,995, 992, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1232, sellCostBuyPrice =sellCostBuyPrice+995
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+995, sellCostMeanBuyPrice = sellCostMeanBuyPrice+992
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+995, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+992
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+993.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+995
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+992
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (10298, '2024-12-18', 1232, 995, 995
                    , 992, 995, 992, 993.33
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,995, 992, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1232, sellCostBuyPrice =sellCostBuyPrice+995
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+995, sellCostMeanBuyPrice = sellCostMeanBuyPrice+992
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+995, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+992
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+993.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+995
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+992
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 995, 995
                    , 992, 995, 992, 993.33, 995, 992)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1232, netSellCostBuyPrice = netSellCostBuyPrice+995
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+995
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+992
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+995
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+992
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+993.33
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+995
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+992;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762b977a2c2f and sellbillId = 150012 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762b63d08429
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7349,@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-18 13:47:09', '06762b63d08429', '7349', '1556.00', '2182', '0', '1', '626.00', '626', '0', '626', '1', '2024-12-18 14:15:10', '', '75', '0', 'نهي عزت الوادي الجديد Y349', '2', '1', '3', '80', 'نهي عزت الوادي الجديد Y349', '2' ,'0','','','','','-1','0','0','0','0','0','626','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '2182', userid = '75' WHERE clientid = '7349';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7349','1556.00','626','0','اضافة فاتورة مبيعات','150013', '2182', '2024-12-18 14:15:10', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '626', '0', null, '0', null, null,'', '0','1','1','626','1','2024-12-18 13:47:09','0','0');
UPDATE client SET  inUse = 0 where clientid = 7349;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35347;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1540', '150013', '14', '16017', '1', '620', '620', '0', '', '1', '2024-12-18 14:15:10', '16017', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35347-1,','1','1','0','0','620','620','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 = 547992;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16017, '2024-12-18', 620, 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+620, 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-18', 620, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0, 510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, 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 = '75', storedetaildate = '2024-12-18 14:15:10' WHERE storedetailid = '16016';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16017', '1', '1', '1', '150013', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-18 14:15: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 ('0','10291', '150013', '17', '10291', '1', '6', '6', '0', '', '1', '2024-12-18 14:15:10', '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 = 80 where clientid = 7349;
 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-18', 626, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+626, 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 (7349, '2024-12-18', 626, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+626, 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, 626, 510, 510
                    , 510, 510, 510, 510, 510, 510)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+626, 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 add end - with serial 06762b63d08429 and sellbillId = 150013 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:45:10";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:15:10", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:15:10', '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-18 10:46:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:16:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:16:01', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762bc83d46b0
-- ----------------------------------------------------------------------------------------------------

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-18 14:13:55', '06762bc83d46b0', '1', '0.00', '0', '0', '1', '470.00', '470', '470', '0', '1', '2024-12-18 14:16:01', '', '104', '0', 'نقدي', '1', '0', '3', '24', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150014', '0', '2024-12-18 14:16:01', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '470', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 14:13:55','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35705;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1423', '150014', '14', '15709', '1', '470', '470', '0', '', '1', '2024-12-18 14:16:01', '15709', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35705-1,','1','1','0','0','470','470','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 = 547994;
 INSERT INTO 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-18', 470, 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+470, 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-18', 470, 390, 390
                    , 390, 390, 390, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0, 390, 390, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, 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 = '65', userid = '104', storedetaildate = '2024-12-18 14:16:01' WHERE storedetailid = '15708';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15709', '1', '1', '1', '150014', 'اضافة فاتورة مبيعات', 'sellbillController.php', '66', '65', '104', '2024-12-18 14:16:01','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '14425',  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 ('13955','470', '0', '1', 'اضافة فاتورة مبيعات', '150014', '14425', '2024-12-18 14:16:01', '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-18', 470, 390, 390
                    , 390, 390, 390, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,390, 390, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, 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;
 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-18', 470, 390, 390
                    , 390, 390, 390, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,390, 390, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, 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;
 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 06762bc83d46b0 and sellbillId = 150014 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762bccf06aec
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1642,@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-18 14:15:11', '06762bccf06aec', '1642', '0.00', '273', '0', '1', '273.00', '273', '0', '273', '1', '2024-12-18 14:16:13', '', '75', '0', 'مايسة الجوهري y112', '2', '1', '3', '80', 'مايسة الجوهري y112', '3' ,'0','','','','','-1','0','0','0','0','0','273','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '273', userid = '75' WHERE clientid = '1642';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1642','0.00','273','0','اضافة فاتورة مبيعات','150015', '273', '2024-12-18 14:16:13', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '273', '0', null, '0', null, null,'', '0','1','1','273','1','2024-12-18 14:15:11','0','0');
UPDATE client SET  inUse = 0 where clientid = 1642;
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', '150015', '14', '16298', '1', '250', '250', '0', '', '1', '2024-12-18 14:16:13', '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 = 547995;
 INSERT INTO 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-18', 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-18', 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 = '32', userid = '75', storedetaildate = '2024-12-18 14:16:13' WHERE storedetailid = '16297';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16298', '1', '1', '1', '150015', 'اضافة فاتورة مبيعات', 'sellbillController.php', '33', '32', '75', '2024-12-18 14:16: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', '150015', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 14:16: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', '150015', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-18 14:16:13', '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 = 1642;
 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-18', 273, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,185, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+273, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1642, '2024-12-18', 273, 185, 185
                    , 185, 185, 185, 185
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,185, 185, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+273, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 273, 185, 185
                    , 185, 185, 185, 185, 185, 185)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+273, netSellCostBuyPrice = netSellCostBuyPrice+185
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+185
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+185
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+185
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+185
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+185
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+185
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+185;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762bccf06aec and sellbillId = 150015 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:46:14";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:16:14", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:16:14', '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-18 10:51:14";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:21:14", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:21: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 06762bd0eb8cc4
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9770,@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-18 14:16:14', '06762bd0eb8cc4', '9770', '-620.00', '329', '0', '1', '949.00', '949', '0', '949', '1', '2024-12-18 14:21:14', '', '75', '0', 'نوسا الغيط 41', '2', '1', '3', '87', 'نوسا الغيط 41', '4' ,'0','','','','','-1','0','0','0','0','0','949','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '329', userid = '75' WHERE clientid = '9770';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9770','-620.00','949','0','اضافة فاتورة مبيعات','150016', '329', '2024-12-18 14:21:14', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '949', '0', null, '0', null, null,'', '0','1','1','949','1','2024-12-18 14:16:14','0','0');
UPDATE client SET  inUse = 0 where clientid = 9770;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33985;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06698', '150016', '5', '15221', '1', '620', '620', '0', '', '1', '2024-12-18 14:21:14', '15221', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33985-1,','1','1','0','0','620','620','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 550.00 , meanbuyprice = 1206.00, lastbuyprice_withDiscount = 550.00, meanbuyprice_withDiscount = 1206.00
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 375, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 547998;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15221, '2024-12-18', 620, 550, 550
                    , 1206, 550, 1206, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 550, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1206
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1206
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , 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-18', 620, 550, 550
                    , 1206, 550, 1206, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1206
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1206
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , 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 = '9', userid = '75', storedetaildate = '2024-12-18 14:21:14' WHERE storedetailid = '15220';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15221', '1', '1', '1', '150016', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-18 14:21:14','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', '150016', '5', '16374', '1', '300', '300', '0', '', '1', '2024-12-18 14:21:14', '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 = 547999;
 INSERT INTO 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-18', 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-18', 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 = '19', userid = '75', storedetaildate = '2024-12-18 14:21:14' WHERE storedetailid = '16373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16374', '1', '1', '1', '150016', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '75', '2024-12-18 14:21: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', '150016', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 14:21: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', '150016', '17', '10291', '1', '9', '9', '0', '', '1', '2024-12-18 14:21:14', '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 = 87 where clientid = 9770;
 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-18', 949, 775, 775
                    , 1437, 775, 1437, 787.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,775, 613, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+949, sellCostBuyPrice =sellCostBuyPrice+775
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+775, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1437
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+775, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1437
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+787.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+775
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+613
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (9770, '2024-12-18', 949, 775, 775
                    , 1437, 775, 1437, 787.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,775, 613, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+949, sellCostBuyPrice =sellCostBuyPrice+775
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+775, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1437
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+775, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1437
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+787.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+775
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+613
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 949, 775, 775
                    , 1437, 775, 1437, 787.5, 775, 613)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+949, netSellCostBuyPrice = netSellCostBuyPrice+775
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+775
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1437
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+775
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1437
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+787.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+775
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+613;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762bd0eb8cc4 and sellbillId = 150016 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:51:15";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:21:15", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:21: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-18 10:53:00";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:23:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:23:00', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762bd01e246f
-- ----------------------------------------------------------------------------------------------------

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-18 14:16:01', '06762bd01e246f', '1', '0.00', '0', '0', '1', '1760.00', '1760', '1760', '0', '1', '2024-12-18 14:23:01', '', '104', '0', 'نقدي', '1', '0', '3', '94', 'نقدي', '6' ,'0','','','','','-1','0','0','0','0','0','1760','0','','0','0','1760','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150017', '0', '2024-12-18 14:23:01', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1760', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 14:16:01','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', '150017', '14', '16016', '1', '300', '300', '0', '', '1', '2024-12-18 14:23:01', '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 = 548002;
 INSERT INTO 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-18', 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-18', 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 = '18', userid = '104', storedetaildate = '2024-12-18 14:23:01' WHERE storedetailid = '16015';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16016', '1', '1', '1', '150017', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '104', '2024-12-18 14:23:01','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', '150017', '14', '16407', '1', '380', '380', '0', '', '1', '2024-12-18 14:23:01', '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 = 548003;
 INSERT INTO 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-18', 380, 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+380, 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-18', 380, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, 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 = '12', userid = '104', storedetaildate = '2024-12-18 14:23:01' WHERE storedetailid = '16406';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16407', '1', '1', '1', '150017', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '104', '2024-12-18 14:23:01','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', '150017', '1', '16417', '1', '200', '200', '0', '', '1', '2024-12-18 14:23:01', '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 = 548004;
 INSERT INTO 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-18', 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-18', 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 = '6', userid = '104', storedetaildate = '2024-12-18 14:23:01' WHERE storedetailid = '16416';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16417', '1', '1', '1', '150017', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-18 14:23:01','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', '150017', '14', '16298', '1', '250', '250', '0', '', '1', '2024-12-18 14:23:01', '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 = 548005;
 INSERT INTO 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-18', 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-18', 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 = '31', userid = '104', storedetaildate = '2024-12-18 14:23:01' WHERE storedetailid = '16297';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16298', '1', '1', '1', '150017', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32', '31', '104', '2024-12-18 14:23:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36323;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07289', '150017', '5', '16419', '1', '270', '270', '0', '', '1', '2024-12-18 14:23:01', '16419', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36323-1,','1','1','0','0','270','270','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 = 548006;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16419, '2024-12-18', 270, 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+270, 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-18', 270, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, 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 = '10', userid = '104', storedetaildate = '2024-12-18 14:23:01' WHERE storedetailid = '16418';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16419', '1', '1', '1', '150017', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '104', '2024-12-18 14:23:01','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', '150017', '5', '15654', '1', '360', '360', '0', '', '1', '2024-12-18 14:23:01', '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 = 113.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 113.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 113, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 548007;
 INSERT INTO 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-18', 360, 295, 295
                    , 113, 295, 113, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 113, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+113
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+113
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+113
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 360, 295, 295
                    , 113, 295, 113, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 113, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+113
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+113
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+113
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 14:23:01' WHERE storedetailid = '15653';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15654', '1', '1', '1', '150017', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-4', '-5', '104', '2024-12-18 14:23:01','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '16185',  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 ('14425','1760', '0', '1', 'اضافة فاتورة مبيعات', '150017', '16185', '2024-12-18 14:23:01', '104',  '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-18', 1760, 1335, 1335
                    , 1141, 1335, 1141, 1335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1335, 1130, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1760, sellCostBuyPrice =sellCostBuyPrice+1335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1141
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1141
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1130
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1760, 1335, 1335
                    , 1141, 1335, 1141, 1335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1335, 1130, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1760, sellCostBuyPrice =sellCostBuyPrice+1335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1141
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1141
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1130
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1760, 1335, 1335
                    , 1141, 1335, 1141, 1335, 1335, 1130)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1760, netSellCostBuyPrice = netSellCostBuyPrice+1335
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1335
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1141
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1335
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1141
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1335
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1335
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1130;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762bd01e246f and sellbillId = 150017 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762bea617867
-- ----------------------------------------------------------------------------------------------------

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-18 14:23:02', '06762bea617867', '1', '0.00', '0', '0', '1', '220.00', '220', '220', '0', '1', '2024-12-18 14:25:30', '', '104', '0', 'نقدي', '1', '0', '3', '99', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150018', '0', '2024-12-18 14:25:30', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '220', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 14:23:02','0','0');
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', '150018', '5', '16377', '1', '220', '220', '0', '', '1', '2024-12-18 14:25:30', '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 = 548008;
 INSERT INTO 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-18', 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-18', 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 = '34', userid = '104', storedetaildate = '2024-12-18 14:25:30' WHERE storedetailid = '16376';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16377', '1', '1', '1', '150018', 'اضافة فاتورة مبيعات', 'sellbillController.php', '35', '34', '104', '2024-12-18 14:25:30','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '16405',  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 ('16185','220', '0', '1', 'اضافة فاتورة مبيعات', '150018', '16405', '2024-12-18 14:25:30', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 99 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-18', 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;
 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-18', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 220, 170, 170
                    , 170, 170, 170, 170, 170, 170)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+220, 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 06762bea617867 and sellbillId = 150018 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762b60391e05
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9962,@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-18 13:46:11', '06762b60391e05', '9962', '15.00', '328', '0', '1', '313.00', '313', '0', '313', '1', '2024-12-18 14:25:37', '', '75', '0', 'سارة عماد 13', '2', '1', '3', '85', 'سارة عماد 13', '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-18','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '328', userid = '75' WHERE clientid = '9962';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9962','15.00','313','0','اضافة فاتورة مبيعات','150019', '328', '2024-12-18 14:25:37', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '313', '0', null, '0', null, null,'', '0','1','1','313','1','2024-12-18 13:46:11','0','0');
UPDATE client SET  inUse = 0 where clientid = 9962;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35853;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07181', '150019', '5', '16262', '1', '290', '290', '0', '', '1', '2024-12-18 14:25:37', '16262', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35853-1,','1','1','0','0','290','290','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 = 548009;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16262, '2024-12-18', 290, 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+290, 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-18', 290, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, 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 = '6', userid = '75', storedetaildate = '2024-12-18 14:25:37' WHERE storedetailid = '16261';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16262', '1', '1', '1', '150019', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-18 14:25: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', '150019', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 14:25: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', '150019', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-18 14:25: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 = 85 where clientid = 9962;
 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-18', 313, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+313, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9962, '2024-12-18', 313, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+313, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 313, 235, 235
                    , 235, 235, 235, 235, 235, 235)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+313, netSellCostBuyPrice = netSellCostBuyPrice+235
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+235
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+235
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+235
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+235
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+235
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+235
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+235;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762b60391e05 and sellbillId = 150019 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:55:37";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:25:38", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:25:38', '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-18 10:58:27";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:28:27", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:28: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 06762bf4226c96
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5178,@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-18 14:25:38', '06762bf4226c96', '5178', '35.00', '348', '0', '1', '313.00', '313', '0', '313', '1', '2024-12-18 14:28:28', '', '75', '0', 'ايفون هبه41', '2', '1', '3', '87', 'ايفون هبه41', '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-18','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '348', userid = '75' WHERE clientid = '5178';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5178','35.00','313','0','اضافة فاتورة مبيعات','150020', '348', '2024-12-18 14:28:28', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '313', '0', null, '0', null, null,'', '0','1','1','313','1','2024-12-18 14:25:38','0','0');
UPDATE client SET  inUse = 0 where clientid = 5178;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36285;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1450', '150020', '14', '15831', '1', '290', '290', '0', '', '1', '2024-12-18 14:28:28', '15831', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36285-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 270.00
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 275, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 548012;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15831, '2024-12-18', 290, 265, 265
                    , 270, 265, 270, 252.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 265, 275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+252.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 290, 265, 265
                    , 270, 265, 270, 252.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+252.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 14:28:28' WHERE storedetailid = '15830';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15831', '1', '1', '1', '150020', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-18 14:28: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', '150020', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 14:28: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', '150020', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-18 14:28: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 = 87 where clientid = 5178;
 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-18', 313, 265, 265
                    , 270, 265, 270, 252.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,265, 275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+313, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+252.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (5178, '2024-12-18', 313, 265, 265
                    , 270, 265, 270, 252.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,265, 275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+313, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+252.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 265, 265
                    , 270, 265, 270, 252.5, 265, 275)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+313, netSellCostBuyPrice = netSellCostBuyPrice+265
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+265
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+270
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+265
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+270
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+252.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+265
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+275;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762bf4226c96 and sellbillId = 150020 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:58:28";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:28:28", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:28: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-18 10:59:09";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:29:09", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:29:09', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762be3b7c4f6
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8406,@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-18 14:21:15', '06762be3b7c4f6', '8406', '0.00', '1374', '0', '1', '1374.00', '1374', '0', '1374', '1', '2024-12-18 14:29:09', '', '75', '0', 'مي احمد طنطا W351', '2', '1', '3', '83', 'مي احمد طنطا W351', '5' ,'0','','','','','-1','0','0','0','0','0','1374','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1374', userid = '75' WHERE clientid = '8406';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8406','0.00','1374','0','اضافة فاتورة مبيعات','150021', '1374', '2024-12-18 14:29:09', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1374', '0', null, '0', null, null,'', '0','1','1','1374','1','2024-12-18 14:21:15','0','0');
UPDATE client SET  inUse = 0 where clientid = 8406;
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', '150021', '1', '16365', '1', '610', '610', '0', '', '1', '2024-12-18 14:29:09', '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 = 548015;
 INSERT INTO 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-18', 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-18', 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 = '9', userid = '75', storedetaildate = '2024-12-18 14:29:09' WHERE storedetailid = '16364';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16365', '1', '1', '1', '150021', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-18 14:29:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36182;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07074', '150021', '5', '16052', '1', '400', '400', '0', '', '1', '2024-12-18 14:29:09', '16052', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36182-1,','1','1','0','0','400','400','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 = 548016;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16052, '2024-12-18', 400, 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+400, 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-18', 400, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, 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 = '17', userid = '75', storedetaildate = '2024-12-18 14:29:09' WHERE storedetailid = '16051';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16052', '1', '1', '1', '150021', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '75', '2024-12-18 14:29:09','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', '150021', '5', '16275', '1', '330', '330', '0', '', '1', '2024-12-18 14:29:09', '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 = 548017;
 INSERT INTO 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-18', 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-18', 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 = '75', storedetaildate = '2024-12-18 14:29:09' WHERE storedetailid = '16274';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16275', '1', '1', '1', '150021', 'اضافة فاتورة مبيعات', 'sellbillController.php', '41', '40', '75', '2024-12-18 14:29:09','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', '150021', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 14:29:09', '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', '150021', '17', '10291', '1', '14', '14', '0', '', '1', '2024-12-18 14:29:09', '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 = 8406;
 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-18', 1374, 1155, 1155
                    , 1156, 1155, 1156, 1155
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1155, 1156, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1374, sellCostBuyPrice =sellCostBuyPrice+1155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1156
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1156
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1156
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (8406, '2024-12-18', 1374, 1155, 1155
                    , 1156, 1155, 1156, 1155
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1155, 1156, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1374, sellCostBuyPrice =sellCostBuyPrice+1155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1156
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1156
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1156
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1374, 1155, 1155
                    , 1156, 1155, 1156, 1155, 1155, 1156)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1374, netSellCostBuyPrice = netSellCostBuyPrice+1155
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1155
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1156
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1155
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1156
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1155
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1155
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1156;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762be3b7c4f6 and sellbillId = 150021 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:59:10";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:29:10", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:29:10', '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-18 10:59:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:29:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:29:13', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 10:59:27";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:29:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:29:27', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=4');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:02:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:32:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:32:07', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c02782c15
-- ----------------------------------------------------------------------------------------------------

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-18 14:29:27', '06762c02782c15', '1', '0.00', '0', '0', '1', '190.00', '190', '190', '0', '1', '2024-12-18 14:32:07', '', '104', '0', 'نقدي', '1', '0', '4', '0', '610', '420', 'نقدي', '1', '1', '0', '', '', '','','-1','0','0','0','','0','190','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','اضافة فاتورة مبيعات ومردودات','115', '0', '2024-12-18 14:32:07', '104', 'sellbillandruternController.php', 'اضافة فاتورة مبيعات ومردودات', '190', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 14:29:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35722;
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 ('490','H1379', '115', '14', '15622', '1', '610', '610.00', '0', '', '0', '2024-12-18 14:32:07', '0', '15622', '0.00', '-1', '1','0','','','0','0','0','0','0','0','35722-1,','1','1','','0','0','610','610','0','','','0');
UPDATE sellandruternbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 501.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 501.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 509, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 300;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15622, '2024-12-18', 610, 500, 500
                    , 501, 500, 501, 425.29
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 509, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+501
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+501
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+509
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 610, 500, 500
                    , 501, 500, 501, 425.29
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 509, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+501
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+501
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+509
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 14:32:07' WHERE storedetailid = '15621';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15622', '1', '1', '1', '115', 'فاتوره مبيعات ومردودات', 'sellbillandruternController.php', '20', '19', '104', '2024-12-18 14:32:07','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 ('360.00','06980', '115', '5', '15944', '1', '420', '420', '0', '', '0', '2024-12-18 14:32:07', '1', '15944', '0.00', '-1', '1','0','','','0','0','0','0','0','0','','1','1','','0','0','420','420','0','','','0');
UPDATE sellandruternbilldetail 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 = 301;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15944, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 420, 360, 360, 360
                    , 360, 360, 360, 0, 1, 0, 0, 360, 360)
                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+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+360, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+360
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+360
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+360
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+360
                        , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 420, 360, 360, 360
                    , 360, 360, 360, 0, 0, 360, 360)
                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+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+360, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+360
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+360
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+360
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+360;
UPDATE storedetail SET  productquantity = '16', userid = '104', storedetaildate = '2024-12-18 14:32:07' WHERE storedetailid = '15943';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15944', '1', '1', '0', '115', 'اضافة فاتورة مردودات مبيعات', 'sellbillandruternController.php', '15', '16', '104', '2024-12-18 14:32:07','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '16595',  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 ('16405','190', '0', '1', 'اضافة فاتورة مبيعات ومردودات', '115', '16595', '2024-12-18 14:32:07', '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-18', 610, 500, 500
                    , 501, 500, 501, 425.29
                    , 420, 360, 360, 360
                    , 360, 360, 360 ,500, 509, 360, 360)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+501
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+501
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+509
                        , returnSellVal = returnSellVal+420, returnSellCostBuyPrice = returnSellCostBuyPrice+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+360, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+360
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+360
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+360
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+360;
 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-18', 610, 500, 500
                    , 501, 500, 501, 425.29
                    , 420, 360, 360, 360
                    , 360, 360, 360 ,500, 509, 360, 360)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+501
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+501
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+509
                        , returnSellVal = returnSellVal+420, returnSellCostBuyPrice = returnSellCostBuyPrice+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+360, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+360
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+360
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+360
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+360;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 190, 140, 140
                    , 141, 140, 141, 65.29, 140, 149)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+190, netSellCostBuyPrice = netSellCostBuyPrice+140
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+140
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+141
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+140
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+141
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+65.29
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+140
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+149;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c02782c15 and sellbillId = 115 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:02:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:32:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-18 14:32:07', '104', 'editprint', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=editprint&id=115');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:02:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:32:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:32:52', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:03:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:33:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:33:26', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c0f4ec3fb
-- ----------------------------------------------------------------------------------------------------

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-18 14:32:52', '06762c0f4ec3fb', '1', '0.00', '0', '0', '1', '620.00', '620', '620', '0', '1', '2024-12-18 14:33:26', '', '104', '0', 'نقدي', '1', '0', '3', '26', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','620','0','','0','0','620','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150022', '0', '2024-12-18 14:33:26', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '620', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 14:32:52','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36016;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07164', '150022', '5', '16350', '1', '620', '620', '0', '', '1', '2024-12-18 14:33:27', '16350', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36016-1,','1','1','0','0','620','620','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 = 575, lastbuyprice_withDiscountAndTax = 575
                where sellbilldetailid = 548020;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16350, '2024-12-18', 620, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 575, 575, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+575
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 620, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0, 575, 575, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+575
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 14:33:27' WHERE storedetailid = '16349';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16350', '1', '1', '1', '150022', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-18 14:33:27','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '17215',  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 ('16595','620', '0', '1', 'اضافة فاتورة مبيعات', '150022', '17215', '2024-12-18 14:33:27', '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-18', 620, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,575, 575, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+575
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 620, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,575, 575, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+575
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 620, 575, 575
                    , 575, 575, 575, 575, 575, 575)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+620, netSellCostBuyPrice = netSellCostBuyPrice+575
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+575
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+575
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+575
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+575
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+575
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+575
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+575;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c0f4ec3fb and sellbillId = 150022 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c117be255
-- ----------------------------------------------------------------------------------------------------

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-18 14:33:27', '06762c117be255', '1', '0.00', '0', '0', '1', '580.00', '580', '580', '0', '1', '2024-12-18 14:33:54', '', '104', '0', 'نقدي', '1', '0', '3', '25', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','580','0','','0','0','580','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150023', '0', '2024-12-18 14:33:54', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '580', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 14:33:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35910;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150023', '5', '16297', '1', '580', '580', '0', '', '1', '2024-12-18 14:33:54', '16297', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35910-1,','1','1','0','0','580','580','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 = 548021;
 INSERT INTO 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-18', 580, 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+580, 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-18', 580, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0, 510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, 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 = '51', userid = '104', storedetaildate = '2024-12-18 14:33:54' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '1', '150023', 'اضافة فاتورة مبيعات', 'sellbillController.php', '52', '51', '104', '2024-12-18 14:33:54','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '17795',  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 ('17215','580', '0', '1', 'اضافة فاتورة مبيعات', '150023', '17795', '2024-12-18 14:33:54', '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-18', 580, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, 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 (1, '2024-12-18', 580, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, 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, 580, 510, 510
                    , 510, 510, 510, 510, 510, 510)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+580, 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 add end - with serial 06762c117be255 and sellbillId = 150023 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c0167849f
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8964,@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-18 14:29:10', '06762c0167849f', '8964', '0.00', '2424', '0', '1', '2424.00', '2424', '0', '2424', '1', '2024-12-18 14:34:20', '', '75', '0', 'بسنت يوسف y389', '2', '1', '3', '80', 'بسنت يوسف y389', '7' ,'0','','','','','-1','0','0','0','0','0','2424','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '2424', userid = '75' WHERE clientid = '8964';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8964','0.00','2424','0','اضافة فاتورة مبيعات','150024', '2424', '2024-12-18 14:34:20', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2424', '0', null, '0', null, null,'', '0','1','1','2424','1','2024-12-18 14:29:10','0','0');
UPDATE client SET  inUse = 0 where clientid = 8964;
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', '150024', '14', '15405', '1', '820', '820', '0', '', '1', '2024-12-18 14:34:20', '15405', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35676-1,','1','1','0','0','820','820','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 = 548022;
 INSERT INTO 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-18', 820, 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+820, 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-18', 820, 735, 735
                    , 704, 735, 704, 690.83
                    , 0, 0, 0, 0
                    , 0, 0, 0, 735, 599, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+820, 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 = '4', userid = '75', storedetaildate = '2024-12-18 14:34:20' WHERE storedetailid = '15404';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15405', '1', '1', '1', '150024', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 14:34:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36061;
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', '150024', '5', '15673', '3', '360', '1080', '0', '', '1', '2024-12-18 14:34:20', '15673', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36061-2,36336-1,','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 = 548023;
 INSERT INTO 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-18', 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-18', 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 = '39', userid = '75', storedetaildate = '2024-12-18 14:34:20' WHERE storedetailid = '15672';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15673', '1', '3', '1', '150024', 'اضافة فاتورة مبيعات', 'sellbillController.php', '42', '39', '75', '2024-12-18 14:34:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34821;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06944', '150024', '5', '15819', '1', '480', '480', '0', '', '1', '2024-12-18 14:34:20', '15819', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34821-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 = 548024;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15819, '2024-12-18', 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-18', 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 = '37', userid = '75', storedetaildate = '2024-12-18 14:34:20' WHERE storedetailid = '15818';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15819', '1', '1', '1', '150024', 'اضافة فاتورة مبيعات', 'sellbillController.php', '38', '37', '75', '2024-12-18 14:34: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', '150024', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 14:34: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', '150024', '17', '10291', '1', '24', '24', '0', '', '1', '2024-12-18 14:34:20', '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 = 80 where clientid = 8964;
 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-18', 2424, 2040, 2040
                    , 2009, 2040, 2009, 1995.83
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2040, 1904, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2424, sellCostBuyPrice =sellCostBuyPrice+2040
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2040, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2009
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2040, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2009
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1995.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2040
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1904
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (8964, '2024-12-18', 2424, 2040, 2040
                    , 2009, 2040, 2009, 1995.83
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2040, 1904, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2424, sellCostBuyPrice =sellCostBuyPrice+2040
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2040, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2009
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2040, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2009
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1995.83
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2040
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1904
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 2424, 2040, 2040
                    , 2009, 2040, 2009, 1995.83, 2040, 1904)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2424, netSellCostBuyPrice = netSellCostBuyPrice+2040
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2040
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2009
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2040
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2009
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1995.83
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2040
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1904;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c0167849f and sellbillId = 150024 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:04:21";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:34:21", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:34: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-18 11:04:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:34:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:34:32', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c1332c560
-- ----------------------------------------------------------------------------------------------------

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-18 14:33:55', '06762c1332c560', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2024-12-18 14:34:32', '', '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-18','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','اضافة فاتورة مبيعات','150025', '0', '2024-12-18 14:34:32', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 14:33:55','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35811;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3313', '150025', '1', '16188', '1', '200', '200', '0', '', '1', '2024-12-18 14:34:32', '16188', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35811-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 144.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 144.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 148, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 548027;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16188, '2024-12-18', 200, 145, 145
                    , 144, 145, 144, 147.46
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 148, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+144
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+144
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+147.46
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+148
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 200, 145, 145
                    , 144, 145, 144, 147.46
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 148, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+144
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+144
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+147.46
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+148
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 14:34:32' WHERE storedetailid = '16187';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16188', '1', '1', '1', '150025', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-18 14:34:32','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '17995',  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 ('17795','200', '0', '1', 'اضافة فاتورة مبيعات', '150025', '17995', '2024-12-18 14:34:32', '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-18', 200, 145, 145
                    , 144, 145, 144, 147.46
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,145, 148, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+144
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+144
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+147.46
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+148
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 200, 145, 145
                    , 144, 145, 144, 147.46
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,145, 148, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+144
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+144
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+147.46
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+148
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 145, 145
                    , 144, 145, 144, 147.46, 145, 148)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+145
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+145
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+144
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+145
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+144
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+147.46
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+145
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+148;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c1332c560 and sellbillId = 150025 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c1592609a
-- ----------------------------------------------------------------------------------------------------

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-18 14:34:33', '06762c1592609a', '1', '0.00', '0', '0', '1', '710.00', '710', '710', '0', '1', '2024-12-18 14:36:47', '', '104', '0', 'نقدي', '1', '0', '3', '26', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','710','0','','0','0','710','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150026', '0', '2024-12-18 14:36:47', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '710', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 14:34:33','0','0');
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', '150026', '14', '16406', '1', '450', '450', '0', '', '1', '2024-12-18 14:36:47', '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 = 548028;
 INSERT INTO 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-18', 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-18', 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 = '10', userid = '104', storedetaildate = '2024-12-18 14:36:47' WHERE storedetailid = '16405';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16406', '1', '1', '1', '150026', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '104', '2024-12-18 14:36:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35849;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1614', '150026', '14', '16258', '1', '260', '260', '0', '', '1', '2024-12-18 14:36:47', '16258', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35849-1,','1','1','0','0','260','260','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 = 548029;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16258, '2024-12-18', 260, 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+260, 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-18', 260, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, 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 = '9', userid = '104', storedetaildate = '2024-12-18 14:36:47' WHERE storedetailid = '16257';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16258', '1', '1', '1', '150026', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-18 14:36:47','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '18705',  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 ('17995','710', '0', '1', 'اضافة فاتورة مبيعات', '150026', '18705', '2024-12-18 14:36:48', '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-18', 710, 545, 545
                    , 545, 545, 545, 545
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,545, 545, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+710, sellCostBuyPrice =sellCostBuyPrice+545
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+545, sellCostMeanBuyPrice = sellCostMeanBuyPrice+545
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+545, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+545
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+545
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+545
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 710, 545, 545
                    , 545, 545, 545, 545
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,545, 545, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+710, sellCostBuyPrice =sellCostBuyPrice+545
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+545, sellCostMeanBuyPrice = sellCostMeanBuyPrice+545
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+545, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+545
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+545
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+545
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 710, 545, 545
                    , 545, 545, 545, 545, 545, 545)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+710, netSellCostBuyPrice = netSellCostBuyPrice+545
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+545
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+545
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+545
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+545
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+545
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+545
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+545;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c1592609a and sellbillId = 150026 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:06:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:36:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:36:48', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:07:03";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:37:03", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:37: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 06762c14d8e103
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7950,@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-18 14:34:21', '06762c14d8e103', '7950', '0.00', '1929', '0', '1', '1929.00', '1929', '0', '1929', '1', '2024-12-18 14:37:03', '', '75', '0', 'اسماء احمد W227', '2', '1', '3', '83', 'اسماء احمد W227', '6' ,'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-18','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1929', userid = '75' WHERE clientid = '7950';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7950','0.00','1929','0','اضافة فاتورة مبيعات','150027', '1929', '2024-12-18 14:37:03', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1929', '0', null, '0', null, null,'', '0','1','1','1929','1','2024-12-18 14:34:21','0','0');
UPDATE client SET  inUse = 0 where clientid = 7950;
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', '150027', '14', '15974', '1', '520', '520', '0', '', '1', '2024-12-18 14:37:03', '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 = 548030;
 INSERT INTO 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-18', 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-18', 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 = '2', userid = '75', storedetaildate = '2024-12-18 14:37:03' WHERE storedetailid = '15973';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15974', '1', '1', '1', '150027', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-18 14:37:03','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', '150027', '14', '16388', '1', '670', '670', '0', '', '1', '2024-12-18 14:37:03', '16388', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36146-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 = 548031;
 INSERT INTO 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-18', 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-18', 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 = '20', userid = '75', storedetaildate = '2024-12-18 14:37:03' WHERE storedetailid = '16387';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16388', '1', '1', '1', '150027', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '75', '2024-12-18 14:37:03','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35895;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150027', '14', '16292', '1', '300', '300', '0', '', '1', '2024-12-18 14:37:03', '16292', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35895-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 = 548032;
 INSERT INTO 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-18', 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-18', 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 = '17', userid = '75', storedetaildate = '2024-12-18 14:37:03' WHERE storedetailid = '16291';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16292', '1', '1', '1', '150027', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '75', '2024-12-18 14:37:03','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35125;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1377', '150027', '14', '15585', '1', '400', '400', '0', '', '1', '2024-12-18 14:37:03', '15585', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35125-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 302.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 302.00
        , lastbuyprice_withTax = 310, meanbuyprice_withTax = 275, lastbuyprice_withDiscountAndTax = 310
                where sellbilldetailid = 548033;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15585, '2024-12-18', 400, 310, 310
                    , 302, 310, 302, 303.04
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 310, 275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+303.04
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 400, 310, 310
                    , 302, 310, 302, 303.04
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+303.04
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 14:37:03' WHERE storedetailid = '15584';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15585', '1', '1', '1', '150027', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-18 14:37: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', '150027', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 14:37: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', '150027', '17', '10291', '1', '19', '19', '0', '', '1', '2024-12-18 14:37:03', '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 = 83 where clientid = 7950;
 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-18', 1929, 1545, 1545
                    , 1537, 1545, 1537, 1538.04
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1545, 1510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1929, sellCostBuyPrice =sellCostBuyPrice+1545
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1545, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1537
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1545, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1537
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1538.04
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1510
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (7950, '2024-12-18', 1929, 1545, 1545
                    , 1537, 1545, 1537, 1538.04
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1545, 1510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1929, sellCostBuyPrice =sellCostBuyPrice+1545
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1545, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1537
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1545, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1537
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1538.04
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1510
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1545, 1545
                    , 1537, 1545, 1537, 1538.04, 1545, 1510)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1929, netSellCostBuyPrice = netSellCostBuyPrice+1545
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1545
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1537
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1545
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1537
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1538.04
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1545
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1510;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c14d8e103 and sellbillId = 150027 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:07:04";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:37:04", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:37: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-18 11:08:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:38:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:38:21', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762bf3b59424
-- ----------------------------------------------------------------------------------------------------

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-18 14:25:31', '06762bf3b59424', '1', '0.00', '0', '0', '1', '800.00', '800', '800', '0', '1', '2024-12-18 14:38:21', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150028', '0', '2024-12-18 14:38:21', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '800', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 14:25:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150028', '5', '16279', '2', '400', '800', '0', '', '1', '2024-12-18 14:38:21', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36150-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 = 285, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 548036;
 INSERT INTO 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-18', 800, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 670, 570, 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+570
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 800, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0, 670, 570, 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+570
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 14:38:21' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '2', '1', '150028', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29', '27', '104', '2024-12-18 14:38:21','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '19505',  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 ('18705','800', '0', '1', 'اضافة فاتورة مبيعات', '150028', '19505', '2024-12-18 14:38:21', '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-18', 800, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,670, 570, 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+570
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 800, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,670, 570, 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+570
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 670, 670
                    , 670, 670, 670, 670, 670, 570)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+800, netSellCostBuyPrice = netSellCostBuyPrice+670
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+670
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+670
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+670
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+670
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+670
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+670
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+570;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762bf3b59424 and sellbillId = 150028 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:08:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:38:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:38:22', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:09:21";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:39:21", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:39: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-18 11:09:52";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:39:52", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:39:52', '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 ('ادم المهندسين' , '', '', '01274947970', '0', '', '0', '2024-12-18 14:39:54', '104', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-18','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10740', '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 ('10740','0','0','0','إضافة عميل جديد','10740', '0', '2024-12-18 14:39:54', '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 ('ادم المهندسين', 'ادم المهندسين', 'ادم المهندسين', 'ادم المهندسين', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '104', '0', '2024-12-18 14:39:54');
UPDATE client SET clientname = 'ادم المهندسين', clientaddress = '', clientphone = '', clientmobile = '01274947970', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-18', 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='12549',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10740';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:12:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:42:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:42:34', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c23e62c97
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10740,@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-18 14:38:22', '06762c23e62c97', '10740', '0.00', '222', '0', '1', '222.00', '222', '0', '222', '1', '2024-12-18 14:42:34', '', '104', '0', 'ادم المهندسين', '1', '1', '3', '3', 'ادم المهندسين', '2' ,'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-18','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '222', userid = '104' WHERE clientid = '10740';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10740','0.00','222','0','اضافة فاتورة مبيعات','150029', '222', '2024-12-18 14:42:34', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '222', '0', null, '0', null, null,'', '0','1','1','222','1','2024-12-18 14:38:22','0','0');
UPDATE client SET  inUse = 0 where clientid = 10740;
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', '150029', '5', '8609', '1', '220', '220', '0', '', '1', '2024-12-18 14:42:34', '8609', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','18297-1,','1','1','0','0','220','220','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 = 548037;
 INSERT INTO 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-18', 220, 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+220, 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-18', 220, 340, 340
                    , 363, 340, 363, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, 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 = '4', userid = '104', storedetaildate = '2024-12-18 14:42:34' WHERE storedetailid = '8608';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('8609', '1', '1', '1', '150029', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-18 14:42: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 ('0','10291', '150029', '17', '10291', '1', '2', '2', '0', '', '1', '2024-12-18 14:42:34', '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 = 3 where clientid = 10740;
 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-18', 222, 340, 340
                    , 363, 340, 363, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+222, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10740, '2024-12-18', 222, 340, 340
                    , 363, 340, 363, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+222, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 222, 340, 340
                    , 363, 340, 363, 340, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+222, netSellCostBuyPrice = netSellCostBuyPrice+340
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+340
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+363
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+340
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+363
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+340
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c23e62c97 and sellbillId = 150029 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c33b65489
-- ----------------------------------------------------------------------------------------------------

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-18 14:42:35', '06762c33b65489', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-18 14:43:54', '', '104', '0', 'نقدي', '1', '0', '3', '93', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150030', '0', '2024-12-18 14:43:54', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 14:42:35','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', '150030', '5', '16374', '1', '300', '300', '0', '', '1', '2024-12-18 14:43:54', '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 = 548039;
 INSERT INTO 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-18', 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-18', 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 = '18', userid = '104', storedetaildate = '2024-12-18 14:43:54' WHERE storedetailid = '16373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16374', '1', '1', '1', '150030', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '104', '2024-12-18 14:43:54','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '19805',  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 ('19505','300', '0', '1', 'اضافة فاتورة مبيعات', '150030', '19805', '2024-12-18 14:43:54', '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-18', 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-18', 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 06762c33b65489 and sellbillId = 150030 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:13:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:43:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:43:55', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:15:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:45:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 14:45:11', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:15:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:45:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 14:45:24', '104', 'add', '192.168.1.13', '', '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-18', '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 = '19795',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('19805.00','10', '1', '1', 'إضافة مصروف', '25822', '19795', '2024-12-18 14:45:24', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'فرق فاتورة', expensesdetails = '', expensesValue = '10.00', expensesdate = '2024-12-18', 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 = '25822';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:15:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:45:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 14:45:25', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:15:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:45:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 14:45:26', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:15:47";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:45:47", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:45:47', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c298ac7ba
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8825,@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-18 14:39:52', '06762c298ac7ba', '8825', '0.00', '2071', '0', '1', '2071.00', '2071', '0', '2071', '1', '2024-12-18 14:45:47', '', '75', '0', 'ياسمين حجاج k21', '2', '1', '3', '52', 'ياسمين حجاج k21', '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-18','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 = '8825';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8825','0.00','2071','0','اضافة فاتورة مبيعات','150031', '2071', '2024-12-18 14:45:47', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2071', '0', null, '0', null, null,'', '0','1','1','2071','1','2024-12-18 14:39:52','0','0');
UPDATE client SET  inUse = 0 where clientid = 8825;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 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', '150031', '5', '16331', '1', '300', '300', '0', '', '1', '2024-12-18 14:45:47', '16331', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35986-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 = 548040;
 INSERT INTO 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-18', 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-18', 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 = '41', userid = '75', storedetaildate = '2024-12-18 14:45:47' WHERE storedetailid = '16330';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16331', '1', '1', '1', '150031', 'اضافة فاتورة مبيعات', 'sellbillController.php', '42', '41', '75', '2024-12-18 14:45:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36317;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07199', '150031', '5', '16299', '1', '200', '200', '0', '', '1', '2024-12-18 14:45:47', '16299', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36317-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 = 548041;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16299, '2024-12-18', 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-18', 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 = '12', userid = '75', storedetaildate = '2024-12-18 14:45:47' WHERE storedetailid = '16298';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16299', '1', '1', '1', '150031', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-18 14:45:47','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', '150031', '5', '16337', '1', '280', '280', '0', '', '1', '2024-12-18 14:45:47', '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 = 548042;
 INSERT INTO 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-18', 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-18', 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 = '22', userid = '75', storedetaildate = '2024-12-18 14:45:47' WHERE storedetailid = '16336';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16337', '1', '1', '1', '150031', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '75', '2024-12-18 14:45:47','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', '150031', '5', '16294', '1', '210', '210', '0', '', '1', '2024-12-18 14:45:47', '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 = 146.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 146.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 152, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 548043;
 INSERT INTO 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-18', 210, 140, 155
                    , 146, 155, 146, 152.86
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 152, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+146
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+146
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+152.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+152
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 210, 140, 155
                    , 146, 155, 146, 152.86
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 152, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+146
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+146
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+152.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+152
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '75', storedetaildate = '2024-12-18 14:45:47' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '1', '150031', 'اضافة فاتورة مبيعات', 'sellbillController.php', '72', '71', '75', '2024-12-18 14:45:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35932;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07123', '150031', '5', '16150', '2', '240', '480', '0', '', '1', '2024-12-18 14:45:47', '16150', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35932-2,','1','1','0','0','240','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 184.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 184.00
        , lastbuyprice_withTax = 185, meanbuyprice_withTax = 182, lastbuyprice_withDiscountAndTax = 185
                where sellbilldetailid = 548044;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16150, '2024-12-18', 480, 370, 370
                    , 368, 370, 368, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 370, 364, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+368
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+368
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+370
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+364
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 480, 370, 370
                    , 368, 370, 368, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 370, 364, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+368
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+368
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+370
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+364
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 14:45:47' WHERE storedetailid = '16149';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16150', '1', '2', '1', '150031', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '9', '75', '2024-12-18 14:45:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36057;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150031', '5', '16347', '1', '200', '200', '0', '', '1', '2024-12-18 14:45:47', '16347', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36057-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 = 548045;
 INSERT INTO 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-18', 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-18', 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 = '15', userid = '75', storedetaildate = '2024-12-18 14:45:47' WHERE storedetailid = '16346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16347', '1', '1', '1', '150031', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '75', '2024-12-18 14:45:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35771;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150031', '5', '15674', '1', '360', '360', '0', '', '1', '2024-12-18 14:45:47', '15674', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35771-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 = 548046;
 INSERT INTO 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-18', 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-18', 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 = '41', userid = '75', storedetaildate = '2024-12-18 14:45:47' WHERE storedetailid = '15673';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15674', '1', '1', '1', '150031', 'اضافة فاتورة مبيعات', 'sellbillController.php', '42', '41', '75', '2024-12-18 14:45: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', '150031', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 14:45: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', '150031', '17', '10291', '1', '21', '21', '0', '', '1', '2024-12-18 14:45:47', '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 = 52 where clientid = 8825;
 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-18', 2071, 1555, 1570
                    , 1556, 1570, 1556, 1557.86
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1570, 1555, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2071, sellCostBuyPrice =sellCostBuyPrice+1555
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1570, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1556
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1570, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1556
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1557.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1570
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1555
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (8825, '2024-12-18', 2071, 1555, 1570
                    , 1556, 1570, 1556, 1557.86
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1570, 1555, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2071, sellCostBuyPrice =sellCostBuyPrice+1555
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1570, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1556
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1570, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1556
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1557.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1570
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1555
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1555, 1570
                    , 1556, 1570, 1556, 1557.86, 1570, 1555)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2071, netSellCostBuyPrice = netSellCostBuyPrice+1555
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1570
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1556
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1570
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1556
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1557.86
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1570
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1555;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c298ac7ba and sellbillId = 150031 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:15:48";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:45:48", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:45: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-18 11:16:18";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 14:46:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 14:46:18', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:16:35";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 14:46:35", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 14:46:35', '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-18 11:16:40";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 14:46:40", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:46:40', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=148612');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:18:57";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 14:48:57", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 14:48:57', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:19:19";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 14:49:19", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 14:49:19', '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-18 11:19:41";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 14:49:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnsellbillController.php', '2024-12-18 14:49:41', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnsellbillController.php?do=showDetail&returnsellbillid=16809');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:20:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:50:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:50:01', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:20:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:50:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:50:28', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c4f929881
-- ----------------------------------------------------------------------------------------------------

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-18 14:50:01', '06762c4f929881', '1', '0.00', '0', '0', '1', '450.00', '450', '450', '0', '1', '2024-12-18 14:50:28', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150032', '0', '2024-12-18 14:50:28', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '450', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 14:50:01','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', '150032', '5', '16053', '1', '450', '450', '0', '', '1', '2024-12-18 14:50:28', '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 = 548049;
 INSERT INTO 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-18', 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-18', 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 = '12', userid = '104', storedetaildate = '2024-12-18 14:50:28' WHERE storedetailid = '16052';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16053', '1', '1', '1', '150032', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '104', '2024-12-18 14:50:28','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20245',  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 ('19795','450', '0', '1', 'اضافة فاتورة مبيعات', '150032', '20245', '2024-12-18 14:50: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-18', 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-18', 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 06762c4f929881 and sellbillId = 150032 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:20:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:50:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:50:29', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:21:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:51:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 14:51:22', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:21:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:51:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 14:51:24', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:21:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:51:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 14:51:24', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:22:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:52:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 14:52:15', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:22:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:52:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 14:52:18', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:22:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:52:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 14:52:25', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:23:53";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:53:53", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 14:53:53', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:24:00";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:54:00", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:54:00', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c3fcaa4b0
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8799,@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-18 14:45:48', '06762c3fcaa4b0', '8799', '-500.00', '1919', '0', '1', '2419.00', '2419', '0', '2419', '1', '2024-12-18 14:54:00', '', '75', '0', 'دلال فوزي', '2', '1', '3', '83', 'دلال فوزي', '12' ,'0','','','','','-1','0','0','0','0','0','2419','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1919', userid = '75' WHERE clientid = '8799';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8799','-500.00','2419','0','اضافة فاتورة مبيعات','150033', '1919', '2024-12-18 14:54:00', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2419', '0', null, '0', null, null,'', '0','1','1','2419','1','2024-12-18 14:45:48','0','0');
UPDATE client SET  inUse = 0 where clientid = 8799;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 21382;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('475','H1141', '150033', '14', '9779', '1', '510', '510', '0', '', '1', '2024-12-18 14:54:00', '9779', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','21382-1,','1','1','0','0','510','510','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
        
                where sellbilldetailid = 548050;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9779, '2024-12-18', 510, 475, 475
                    , 475, 475, 475, 475
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+475
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 510, 475, 475
                    , 475, 475, 475, 475
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+475
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 14:54:00' WHERE storedetailid = '9778';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9779', '1', '1', '1', '150033', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-18 14:54:00','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30964;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2671', '150033', '1', '13108', '1', '185', '185', '0', '', '1', '2024-12-18 14:54:00', '13108', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30964-1,','1','1','0','0','185','185','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 264.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 264.00
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 66, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 548051;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13108, '2024-12-18', 185, 265, 265
                    , 264, 265, 264, 253.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 265, 66, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+264
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+264
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+253.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+66
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 185, 265, 265
                    , 264, 265, 264, 253.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 66, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+264
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+264
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+253.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+66
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 14:54:00' WHERE storedetailid = '13107';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13108', '1', '1', '1', '150033', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 14:54:00','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35272;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3297', '150033', '1', '15935', '1', '200', '200', '0', '', '1', '2024-12-18 14:54:00', '15935', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35272-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 = 548052;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15935, '2024-12-18', 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-18', 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 = '28', userid = '75', storedetaildate = '2024-12-18 14:54:00' WHERE storedetailid = '15934';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15935', '1', '1', '1', '150033', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29', '28', '75', '2024-12-18 14:54:00','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','B1128', '150033', '2', '13152', '1', '105', '105', '0', '', '1', '2024-12-18 14:54:00', '13152', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','105','105','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 184.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 184.00
        
                where sellbilldetailid = 548053;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13152, '2024-12-18', 105, 185, 185
                    , 184, 185, 184, 177.6
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+105, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+177.6
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 105, 185, 185
                    , 184, 185, 184, 177.6
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+105, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+177.6
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 14:54:00' WHERE storedetailid = '13151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13152', '1', '1', '1', '150033', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-18 14:54:00','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33859;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06733', '150033', '5', '15273', '1', '210', '210', '0', '', '1', '2024-12-18 14:54:00', '15273', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33859-1,','1','1','0','0','210','210','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 = 548054;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15273, '2024-12-18', 210, 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+210, 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-18', 210, 250, 250
                    , 250, 250, 250, 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+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 = '75', storedetaildate = '2024-12-18 14:54:00' WHERE storedetailid = '15272';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15273', '1', '1', '1', '150033', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-18 14:54:00','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32363;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2977', '150033', '1', '14576', '1', '175', '175', '0', '', '1', '2024-12-18 14:54:00', '14576', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32363-1,','1','1','0','0','175','175','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 = 548055;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14576, '2024-12-18', 175, 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+175, 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-18', 175, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+175, 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 = '2', userid = '75', storedetaildate = '2024-12-18 14:54:00' WHERE storedetailid = '14575';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14576', '1', '1', '1', '150033', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-18 14:54:00','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32813;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06470', '150033', '5', '14785', '1', '130', '130', '0', '', '1', '2024-12-18 14:54:00', '14785', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32813-1,','1','1','0','0','130','130','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 270.00
        
                where sellbilldetailid = 548056;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14785, '2024-12-18', 130, 210, 210
                    , 270, 210, 270, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , 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-18', 130, 210, 210
                    , 270, 210, 270, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , 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 = '4', userid = '75', storedetaildate = '2024-12-18 14:54:00' WHERE storedetailid = '14784';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14785', '1', '1', '1', '150033', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 14:54:00','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35306;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1487', '150033', '14', '15909', '1', '370', '370', '0', '', '1', '2024-12-18 14:54:00', '15909', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35306-1,','1','1','0','0','370','370','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 = 320, lastbuyprice_withDiscountAndTax = 320
                where sellbilldetailid = 548057;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15909, '2024-12-18', 370, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, 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+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 370, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, 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 = '24', userid = '75', storedetaildate = '2024-12-18 14:54:00' WHERE storedetailid = '15908';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15909', '1', '1', '1', '150033', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '75', '2024-12-18 14:54:00','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35895;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150033', '14', '16292', '1', '300', '300', '0', '', '1', '2024-12-18 14:54:01', '16292', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35895-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 = 548058;
 INSERT INTO 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-18', 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-18', 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 = '16', userid = '75', storedetaildate = '2024-12-18 14:54:01' WHERE storedetailid = '16291';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16292', '1', '1', '1', '150033', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '75', '2024-12-18 14:54:01','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', '150033', '5', '15436', '1', '190', '190', '0', '', '1', '2024-12-18 14:54:01', '15436', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34153-1,','1','1','0','0','190','190','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 = 548059;
 INSERT INTO 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-18', 190, 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+190, 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-18', 190, 205, 205
                    , 205, 205, 205, 205
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, 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 = '4', userid = '75', storedetaildate = '2024-12-18 14:54:01' WHERE storedetailid = '15435';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15436', '1', '1', '1', '150033', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 14:54: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', '150033', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 14:54: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', '150033', '17', '10291', '1', '24', '24', '0', '', '1', '2024-12-18 14:54:01', '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 = 83 where clientid = 8799;
 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-18', 2419, 2475, 2475
                    , 2533, 2475, 2533, 2455.93
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,960, 761, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2419, sellCostBuyPrice =sellCostBuyPrice+2475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2533
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2533
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2455.93
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+960
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+761
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (8799, '2024-12-18', 2419, 2475, 2475
                    , 2533, 2475, 2533, 2455.93
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,960, 761, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2419, sellCostBuyPrice =sellCostBuyPrice+2475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2533
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2533
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2455.93
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+960
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+761
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 2419, 2475, 2475
                    , 2533, 2475, 2533, 2455.93, 960, 761)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2419, netSellCostBuyPrice = netSellCostBuyPrice+2475
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2475
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2533
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2475
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2533
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2455.93
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+960
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+761;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c3fcaa4b0 and sellbillId = 150033 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:24:01";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:54:01", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:54:01', '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 ('ام حمزة سوهاج 07' , '', '', '01124009087', '0', '', '0', '2024-12-18 14:54:58', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-18','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10741', '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 ('10741','0','0','0','إضافة عميل جديد','10741', '0', '2024-12-18 14:54:58', '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 ('ام حمزة سوهاج 07', 'ام حمزة سوهاج 07', 'ام حمزة سوهاج 07', 'ام حمزة سوهاج 07', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-18 14:54:58');
UPDATE client SET clientname = 'ام حمزة سوهاج 07', clientaddress = '', clientphone = '', clientmobile = '01124009087', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-18', 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='12550',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10741';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:25:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:55:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 14:55:36', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247319
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5150,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 14:55:36', userid = '104' WHERE clientid = '5150';
UPDATE client SET  inUse = 0 where clientid = 5150;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5150','480.00','480','1','ايصال تحصيل (( قبض من عميل ))','247319', '0', '2024-12-18 14:53:54', '104', 'clientPayedDeptController.php', '   ', '480', '0', null, '0', null, null,'', '-1','1','1','480','1','','3502','0');
UPDATE save SET  savecurrentvalue = '20725',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('20245.00','480', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '247321', '20725', '2024-12-18 14:55:36', '104',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '480', '480', '2024-12-18', '104', '0', '0', '2024-12-18 14:55:36','اضافة ايصال سداد للعميل اسماء النمرT33','1','0','-1','0','247321','clientPayedDeptController.php?do=show&id=247321');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122147', '-1', '480', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '480', 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 ('122147', '-1', '480', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-480', 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 = '5150', clientdebtchangebefore = '480.000', clientdebtchangeamount = '480.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247319', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 14:53:54', userid = '104', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '480.00',discount='', reciptid='0', dailyentryid = '122147',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='480',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247321';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247319 -clientdebtchangeId = 247321
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:25:37";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:55:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 14:55:37', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:25:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:55:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 14:55:39', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:25:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:55:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:55:40', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:25:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:55:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:55:41', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:26:34";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:56:34", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:56: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 06762c5e9d1c3e
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10741,@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-18 14:54:01', '06762c5e9d1c3e', '10741', '0.00', '1505', '0', '1', '1505.00', '1505', '0', '1505', '1', '2024-12-18 14:56:34', '', '75', '0', 'ام حمزة سوهاج 07', '2', '1', '3', '52', 'ام حمزة سوهاج 07', '6' ,'0','','','','','-1','0','0','0','0','0','1505','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1505', userid = '75' WHERE clientid = '10741';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10741','0.00','1505','0','اضافة فاتورة مبيعات','150034', '1505', '2024-12-18 14:56:34', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1505', '0', null, '0', null, null,'', '0','1','1','1505','1','2024-12-18 14:54:01','0','0');
UPDATE client SET  inUse = 0 where clientid = 10741;
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', '150034', '14', '16447', '1', '480', '480', '0', '', '1', '2024-12-18 14:56:34', '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 = 548062;
 INSERT INTO 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-18', 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-18', 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 = '19', userid = '75', storedetaildate = '2024-12-18 14:56:34' WHERE storedetailid = '16446';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16447', '1', '1', '1', '150034', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '75', '2024-12-18 14:56: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 ('340','0H785', '150034', '14', '8733', '1', '275', '275', '0', '', '1', '2024-12-18 14:56:34', '8733', '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 = 345.00 , meanbuyprice = 339.00, lastbuyprice_withDiscount = 345.00, meanbuyprice_withDiscount = 339.00
        
                where sellbilldetailid = 548063;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8733, '2024-12-18', 275, 340, 345
                    , 339, 345, 339, 338.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+339
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+339
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+338.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-18', 275, 340, 345
                    , 339, 345, 339, 338.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+339
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+339
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+338.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 = '75', storedetaildate = '2024-12-18 14:56:34' WHERE storedetailid = '8732';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('8733', '1', '1', '1', '150034', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-18 14:56: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 ('320','0H872', '150034', '14', '8923', '1', '305', '305', '0', '', '1', '2024-12-18 14:56:35', '8923', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','305','305','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 = 548064;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8923, '2024-12-18', 305, 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+305, 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-18', 305, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+305, 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 = '0', userid = '75', storedetaildate = '2024-12-18 14:56:35' WHERE storedetailid = '8922';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('8923', '1', '1', '1', '150034', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-18 14:56:35','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', '150034', '14', '16167', '1', '410', '410', '0', '', '1', '2024-12-18 14:56:35', '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 = 548065;
 INSERT INTO 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-18', 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-18', 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 = '18', userid = '75', storedetaildate = '2024-12-18 14:56:35' WHERE storedetailid = '16166';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16167', '1', '1', '1', '150034', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '75', '2024-12-18 14:56: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', '150034', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 14:56: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', '150034', '17', '10291', '1', '15', '15', '0', '', '1', '2024-12-18 14:56:35', '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 = 52 where clientid = 10741;
 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-18', 1505, 1385, 1390
                    , 1383, 1390, 1383, 1380.33
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,725, 724, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1505, sellCostBuyPrice =sellCostBuyPrice+1385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1383
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1383
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1380.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+725
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+724
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (10741, '2024-12-18', 1505, 1385, 1390
                    , 1383, 1390, 1383, 1380.33
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,725, 724, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1505, sellCostBuyPrice =sellCostBuyPrice+1385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1383
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1383
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1380.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+725
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+724
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1505, 1385, 1390
                    , 1383, 1390, 1383, 1380.33, 725, 724)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1505, netSellCostBuyPrice = netSellCostBuyPrice+1385
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1390
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1383
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1390
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1383
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1380.33
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+725
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+724;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c5e9d1c3e and sellbillId = 150034 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:26:35";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 14:56:35", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:56:35', '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-18 11:26:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:56:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:56:46', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c64d3af99
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9683,@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-18 14:55:41', '06762c64d3af99', '9683', '0.00', '404', '0', '1', '404.00', '404', '0', '404', '1', '2024-12-18 14:56:46', '', '104', '0', 'ياسمين عادل ', '1', '1', '3', '74', 'ياسمين عادل ', '2' ,'0','','','','','-1','0','0','0','0','0','404','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '404', userid = '104' WHERE clientid = '9683';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9683','0.00','404','0','اضافة فاتورة مبيعات','150035', '404', '2024-12-18 14:56:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '404', '0', null, '0', null, null,'', '0','1','1','404','1','2024-12-18 14:55:41','0','0');
UPDATE client SET  inUse = 0 where clientid = 9683;
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', '150035', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-18 14:56:46', '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 = 285, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 548068;
 INSERT INTO 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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 285, 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+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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 285, 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+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 = '26', userid = '104', storedetaildate = '2024-12-18 14:56:46' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150035', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27', '26', '104', '2024-12-18 14:56: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', '150035', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-18 14:56:46', '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 = 74 where clientid = 9683;
 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-18', 404, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+404, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , 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 (9683, '2024-12-18', 404, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+404, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , 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, 404, 335, 335
                    , 335, 335, 335, 335, 335, 285)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+404, netSellCostBuyPrice = netSellCostBuyPrice+335
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+335
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+335
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+335
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+335
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+335
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+335
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+285;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c64d3af99 and sellbillId = 150035 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:26:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 14:56:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:56:47', '104', 'addsellBill', '192.168.1.13', '', '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 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;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:29:30";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 14:59:30", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 14:59:30', '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-18 11:29:31";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:29:36";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 14:59:36", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 14:59: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 loginip = "" WHERE lastactivetime < "2024-12-18 11:30:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:00:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:00:32', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c68f99ab0
-- ----------------------------------------------------------------------------------------------------

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-18 14:56:47', '06762c68f99ab0', '1', '0.00', '0', '0', '1', '810.00', '810', '810', '0', '1', '2024-12-18 15:00:32', '', '104', '0', 'نقدي', '1', '0', '3', '95', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','810','0','','0','0','810','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150036', '0', '2024-12-18 15:00:32', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '810', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 14:56:47','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', '150036', '5', '16454', '1', '810', '810', '0', '', '1', '2024-12-18 15:00:32', '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 = 745.00, lastbuyprice_withDiscount = 745.00, meanbuyprice_withDiscount = 745.00
        , lastbuyprice_withTax = 745, meanbuyprice_withTax = 745, lastbuyprice_withDiscountAndTax = 745
                where sellbilldetailid = 548070;
 INSERT INTO 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-18', 810, 745, 745
                    , 745, 745, 745, 745
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 745, 745, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+745
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+745
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+745
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+745
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 810, 745, 745
                    , 745, 745, 745, 745
                    , 0, 0, 0, 0
                    , 0, 0, 0, 745, 745, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+745
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+745
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+745
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+745
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:00:32' WHERE storedetailid = '16453';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16454', '1', '1', '1', '150036', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-18 15:00:32','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '21535',  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 ('20725','810', '0', '1', 'اضافة فاتورة مبيعات', '150036', '21535', '2024-12-18 15:00:32', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 95 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-18', 810, 745, 745
                    , 745, 745, 745, 745
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,745, 745, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+745
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+745
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+745
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+745
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 810, 745, 745
                    , 745, 745, 745, 745
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,745, 745, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+745
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+745
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+745
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+745
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 810, 745, 745
                    , 745, 745, 745, 745, 745, 745)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+810, netSellCostBuyPrice = netSellCostBuyPrice+745
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+745
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+745
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+745
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+745
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+745
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+745
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+745;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c68f99ab0 and sellbillId = 150036 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c6841b3d4
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9085,@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-18 14:56:36', '06762c6841b3d4', '9085', '0.00', '556', '0', '1', '556.00', '556', '0', '556', '1', '2024-12-18 15:00:47', '', '75', '0', 'هبة رضا m222', '2', '1', '3', '100', 'هبة رضا m222', '6' ,'0','','','','','-1','0','0','0','0','0','556','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '556', userid = '75' WHERE clientid = '9085';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9085','0.00','556','0','اضافة فاتورة مبيعات','150037', '556', '2024-12-18 15:00:47', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '556', '0', null, '0', null, null,'', '0','1','1','556','1','2024-12-18 14:56:36','0','0');
UPDATE client SET  inUse = 0 where clientid = 9085;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36289;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06845', '150037', '5', '15576', '1', '110', '110', '0', '', '1', '2024-12-18 15:00:47', '15576', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36289-1,','1','1','0','0','110','110','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 = 160, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 548071;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15576, '2024-12-18', 110, 155, 155
                    , 155, 155, 155, 184.17
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 160, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+110, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+184.17
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , 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-18', 110, 155, 155
                    , 155, 155, 155, 184.17
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 160, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+110, sellCostBuyPrice =sellCostBuyPrice+155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+184.17
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , 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 = '14', userid = '75', storedetaildate = '2024-12-18 15:00:47' WHERE storedetailid = '15575';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15576', '1', '1', '1', '150037', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-18 15:00: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 ('170','06492', '150037', '5', '14840', '1', '110', '110', '0', '', '1', '2024-12-18 15:00:47', '14840', '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 = 180.00 , meanbuyprice = 177.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 177.00
        
                where sellbilldetailid = 548072;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14840, '2024-12-18', 110, 170, 180
                    , 177, 180, 177, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+110, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+177
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+177
                            , 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-18', 110, 170, 180
                    , 177, 180, 177, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+110, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+177
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+177
                            , 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 = '1', userid = '75', storedetaildate = '2024-12-18 15:00:47' WHERE storedetailid = '14839';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14840', '1', '1', '1', '150037', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-18 15:00: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 ('210','05871', '150037', '5', '13098', '1', '100', '100', '0', '', '1', '2024-12-18 15:00:47', '13098', '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 = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
        
                where sellbilldetailid = 548073;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13098, '2024-12-18', 100, 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+100, 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-18', 100, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, 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 = '5', userid = '75', storedetaildate = '2024-12-18 15:00:47' WHERE storedetailid = '13097';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13098', '1', '1', '1', '150037', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-18 15:00:47','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', '150037', '5', '16294', '1', '210', '210', '0', '', '1', '2024-12-18 15:00:47', '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 = 146.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 146.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 152, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 548074;
 INSERT INTO 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-18', 210, 140, 155
                    , 146, 155, 146, 152.86
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 152, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+146
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+146
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+152.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+152
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 210, 140, 155
                    , 146, 155, 146, 152.86
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 152, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+146
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+146
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+152.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+152
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:00:47' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '1', '150037', 'اضافة فاتورة مبيعات', 'sellbillController.php', '71', '70', '75', '2024-12-18 15:00: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', '150037', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 15:00: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', '150037', '17', '10291', '1', '6', '6', '0', '', '1', '2024-12-18 15:00:47', '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 = 100 where clientid = 9085;
 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-18', 556, 675, 700
                    , 688, 700, 688, 722.03
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,310, 312, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+556, sellCostBuyPrice =sellCostBuyPrice+675
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+688
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+688
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+722.03
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+312
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (9085, '2024-12-18', 556, 675, 700
                    , 688, 700, 688, 722.03
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,310, 312, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+556, sellCostBuyPrice =sellCostBuyPrice+675
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+688
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+688
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+722.03
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+312
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 556, 675, 700
                    , 688, 700, 688, 722.03, 310, 312)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+556, netSellCostBuyPrice = netSellCostBuyPrice+675
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+700
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+688
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+700
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+688
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+722.03
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+310
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+312;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c6841b3d4 and sellbillId = 150037 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:30:48";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 15:00:48", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:00: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-18 11:30:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:00:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 15:00:57', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:34:31";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:04:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:04:31', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247286
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9303,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 15:04:31', userid = '2' WHERE clientid = '9303';
UPDATE client SET  inUse = 0 where clientid = 9303;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9303','495.00','495','1','ايصال تحصيل (( قبض من عميل ))','247286', '0', '2024-12-18 13:24:18', '2', 'clientPayedDeptController.php', '   ', '495', '0', null, '0', null, null,'', '-1','1','1','495','1','','3502','0');
UPDATE save SET  savecurrentvalue = '201707.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('201212.50','495', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247326', '201707.5', '2024-12-18 15:04:31', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '495', '495', '2024-12-18', '2', '0', '0', '2024-12-18 15:04:31','اضافة ايصال سداد للعميل ايمان كحيل x1011','1','0','0','0','247326','clientPayedDeptController.php?do=show&id=247326');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122148', '-1', '495', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '495', 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 ('122148', '-1', '495', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-495', 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 = '9303', clientdebtchangebefore = '495.000', clientdebtchangeamount = '495.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247286', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 13:24:18', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '495.00',discount='', reciptid='0', dailyentryid = '122148',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='495',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247326';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247286 -clientdebtchangeId = 247326
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247327
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7349,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 15:04:50', userid = '2' WHERE clientid = '7349';
UPDATE client SET  inUse = 0 where clientid = 7349;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7349','2182.00','2182','1','ايصال تحصيل (( قبض من عميل ))','247327', '0', '2024-12-18 15:04:32', '2', 'clientPayedDeptController.php', '   ', '2182', '0', null, '0', null, null,'', '-1','1','1','2182','1','','3503','0');
UPDATE save SET  savecurrentvalue = '203889.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('201707.50','2182', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247327', '203889.5', '2024-12-18 15:04:50', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '2182', '2182', '2024-12-18', '2', '0', '0', '2024-12-18 15:04:50','اضافة ايصال سداد للعميل نهي عزت الوادي الجديد Y349','1','0','0','0','247327','clientPayedDeptController.php?do=show&id=247327');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122149', '-1', '2182', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '2182', 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 ('122149', '-1', '2182', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-2182', 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 = '7349', clientdebtchangebefore = '2182.000', clientdebtchangeamount = '2182.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247327', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 15:04:32', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '2182.00',discount='', reciptid='0', dailyentryid = '122149',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='2182',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247327';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:34:50";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:04:50", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:04: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-18 11:37:43";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:07:43", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:07:43', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=4');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:38:26";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:08:26", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:08:26', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c738d7183
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4015,@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-18 14:59:36', '06762c738d7183', '4015', '-300.00', '1367', '0', '1', '1667.00', '1667', '0', '1667', '1', '2024-12-18 15:08:26', '', '101', '0', 'صفاء سيد A856', '2', '1', '3', '79', 'صفاء سيد A856', '6' ,'0','','','','','-1','0','0','0','0','0','1667','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1367', userid = '101' WHERE clientid = '4015';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4015','-300.00','1667','0','اضافة فاتورة مبيعات','150038', '1367', '2024-12-18 15:08:26', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1667', '0', null, '0', null, null,'', '0','1','1','1667','1','2024-12-18 14:59:36','0','0');
UPDATE client SET  inUse = 0 where clientid = 4015;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31956;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2904', '150038', '1', '14369', '1', '200', '200', '0', '', '1', '2024-12-18 15:08:26', '14369', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31956-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 = 548077;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14369, '2024-12-18', 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-18', 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 = '4', userid = '101', storedetaildate = '2024-12-18 15:08:26' WHERE storedetailid = '14368';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14369', '1', '1', '1', '150038', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '101', '2024-12-18 15:08:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32344;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2911', '150038', '1', '14377', '1', '190', '190', '0', '', '1', '2024-12-18 15:08:26', '14377', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32344-1,','1','1','0','0','190','190','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 = 548078;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14377, '2024-12-18', 190, 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+190, 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-18', 190, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, 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 = '5', userid = '101', storedetaildate = '2024-12-18 15:08:26' WHERE storedetailid = '14376';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14377', '1', '1', '1', '150038', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '101', '2024-12-18 15:08:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36101;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07257', '150038', '5', '16373', '1', '620', '620', '0', '', '1', '2024-12-18 15:08:27', '16373', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36101-1,','1','1','0','0','620','620','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 = 550, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 548079;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16373, '2024-12-18', 620, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 550, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 620, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:08:27' WHERE storedetailid = '16372';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16373', '1', '1', '1', '150038', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37', '36', '101', '2024-12-18 15:08:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34699;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1420', '150038', '14', '15748', '1', '620', '620', '0', '', '1', '2024-12-18 15:08:27', '15748', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34699-1,','1','1','0','0','620','620','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 = 548080;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15748, '2024-12-18', 620, 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+620, 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-18', 620, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0, 510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, 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 = '101', storedetaildate = '2024-12-18 15:08:27' WHERE storedetailid = '15747';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15748', '1', '1', '1', '150038', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '101', '2024-12-18 15:08: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', '150038', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 15:08: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', '150038', '17', '10291', '1', '17', '17', '0', '', '1', '2024-12-18 15:08:27', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','17','17','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 79 where clientid = 4015;
 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-18', 1667, 1520, 1520
                    , 1520, 1520, 1520, 1520
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1060, 1060, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1667, sellCostBuyPrice =sellCostBuyPrice+1520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1520
                            , 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 (4015, '2024-12-18', 1667, 1520, 1520
                    , 1520, 1520, 1520, 1520
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1060, 1060, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1667, sellCostBuyPrice =sellCostBuyPrice+1520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1520
                            , 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, 1667, 1520, 1520
                    , 1520, 1520, 1520, 1520, 1060, 1060)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1667, netSellCostBuyPrice = netSellCostBuyPrice+1520
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1520
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1520
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1520
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1520
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1520
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1060
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1060;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c738d7183 and sellbillId = 150038 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:38:27";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:08:27", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:08:27', '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-18 11:39:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:09:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:09:06', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c91f4cdf1
-- ----------------------------------------------------------------------------------------------------

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-18 15:07:43', '06762c91f4cdf1', '1', '0.00', '0', '0', '1', '0.00', '0', '0', '0', '1', '2024-12-18 15:09:06', '', '104', '0', 'نقدي', '1', '0', '4', '0', '620', '620', 'نقدي', '1', '1', '0', '', '', '','','-1','0','0','0','','0','0','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','اضافة فاتورة مبيعات ومردودات','116', '0', '2024-12-18 15:09:06', '104', 'sellbillandruternController.php', 'اضافة فاتورة مبيعات ومردودات', '0', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 15:07:43','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36421;
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 ('540','07141', '116', '5', '16165', '1', '620', '620.00', '0', '', '0', '2024-12-18 15:09:06', '0', '16165', '0.00', '-1', '1','0','','','0','0','0','0','0','0','36421-1,','1','1','','0','0','620','620','0','','','0');
UPDATE sellandruternbilldetail 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 = 302;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16165, '2024-12-18', 620, 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+620, 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-18', 620, 540, 540
                    , 540, 540, 540, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 540, 540, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, 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 = '6', userid = '104', storedetaildate = '2024-12-18 15:09:06' WHERE storedetailid = '16164';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16165', '1', '1', '1', '116', 'فاتوره مبيعات ومردودات', 'sellbillandruternController.php', '7', '6', '104', '2024-12-18 15:09:06','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 ('545.00','07278', '116', '5', '16396', '1', '620', '620', '0', '', '0', '2024-12-18 15:09:06', '1', '16396', '0.00', '-1', '1','0','','','0','0','0','0','0','0','','1','1','','0','0','620','620','0','','','0');
UPDATE sellandruternbilldetail SET  lastbuyprice = 545.00 , meanbuyprice = 545.00, lastbuyprice_withDiscount = 545.00, meanbuyprice_withDiscount = 545.00
        , lastbuyprice_withTax = 545, meanbuyprice_withTax = 273, lastbuyprice_withDiscountAndTax = 545
                where sellbilldetailid = 303;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16396, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 620, 545, 545, 545
                    , 545, 545, 545, 0, 1, 0, 0, 545, 273)
                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+620, returnSellCostBuyPrice = returnSellCostBuyPrice+545, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+545
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+545, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+545
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+545
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+545
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+545
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+273
                        , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 620, 545, 545, 545
                    , 545, 545, 545, 0, 0, 545, 273)
                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+620, returnSellCostBuyPrice = returnSellCostBuyPrice+545, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+545
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+545, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+545
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+545
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+545
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+545
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+273;
UPDATE storedetail SET  productquantity = '9', userid = '104', storedetaildate = '2024-12-18 15:09:06' WHERE storedetailid = '16395';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16396', '1', '1', '0', '116', 'اضافة فاتورة مردودات مبيعات', 'sellbillandruternController.php', '8', '9', '104', '2024-12-18 15:09: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-18', 620, 540, 540
                    , 540, 540, 540, 540
                    , 620, 545, 545, 545
                    , 545, 545, 545 ,540, 540, 545, 273)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, 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+620, returnSellCostBuyPrice = returnSellCostBuyPrice+545, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+545
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+545, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+545
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+545
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+545
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+545
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+273;
 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-18', 620, 540, 540
                    , 540, 540, 540, 540
                    , 620, 545, 545, 545
                    , 545, 545, 545 ,540, 540, 545, 273)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, 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+620, returnSellCostBuyPrice = returnSellCostBuyPrice+545, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+545
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+545, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+545
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+545
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+545
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+545
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+273;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 0, -5, -5
                    , -5, -5, -5, -5, -5, 267)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+0, netSellCostBuyPrice = netSellCostBuyPrice+-5
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-5
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-5
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-5
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+267;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c91f4cdf1 and sellbillId = 116 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:39:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:09:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-18 15:09:07', '104', 'editprint', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=editprint&id=116');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:39:50";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:09:50", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:09: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 06762c94bee0d4
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6822,@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-18 15:08:27', '06762c94bee0d4', '6822', '0.00', '434', '0', '1', '434.00', '434', '0', '434', '1', '2024-12-18 15:09:50', '', '101', '0', 'هند السعيد K553', '2', '1', '3', '79', 'هند السعيد K553', '4' ,'0','','','','','-1','0','0','0','0','0','434','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '434', userid = '101' WHERE clientid = '6822';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6822','0.00','434','0','اضافة فاتورة مبيعات','150039', '434', '2024-12-18 15:09:50', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '434', '0', null, '0', null, null,'', '0','1','1','434','1','2024-12-18 15:08:27','0','0');
UPDATE client SET  inUse = 0 where clientid = 6822;
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', '150039', '5', '16294', '1', '210', '210', '0', '', '1', '2024-12-18 15:09:50', '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 = 146.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 146.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 152, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 548083;
 INSERT INTO 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-18', 210, 140, 155
                    , 146, 155, 146, 152.86
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 155, 152, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+146
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+146
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+152.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+152
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 210, 140, 155
                    , 146, 155, 146, 152.86
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 152, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+155, sellCostMeanBuyPrice = sellCostMeanBuyPrice+146
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+146
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+152.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+152
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:09:50' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '1', '150039', 'اضافة فاتورة مبيعات', 'sellbillController.php', '70', '69', '101', '2024-12-18 15:09:50','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', '150039', '5', '16301', '1', '200', '200', '0', '', '1', '2024-12-18 15:09:50', '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 = 548084;
 INSERT INTO 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-18', 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-18', 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 = '6', userid = '101', storedetaildate = '2024-12-18 15:09:50' WHERE storedetailid = '16300';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16301', '1', '1', '1', '150039', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '101', '2024-12-18 15:09: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', '150039', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 15:09: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', '150039', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-18 15:09: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 = 6822;
 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-18', 434, 280, 295
                    , 286, 295, 286, 292.86
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 292, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+434, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+286
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+286
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+292.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+292
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (6822, '2024-12-18', 434, 280, 295
                    , 286, 295, 286, 292.86
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 292, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+434, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+286
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+286
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+292.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+292
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 434, 280, 295
                    , 286, 295, 286, 292.86, 295, 292)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+434, netSellCostBuyPrice = netSellCostBuyPrice+280
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+295
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+286
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+295
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+286
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+292.86
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+295
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+292;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c94bee0d4 and sellbillId = 150039 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:39:51";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:09:51", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:09: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-18 11:40:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:10:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:10:51', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:41:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:11:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:11:34', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c9dbb5d04
-- ----------------------------------------------------------------------------------------------------

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-18 15:10:51', '06762c9dbb5d04', '1', '0.00', '0', '0', '1', '190.00', '190', '190', '0', '1', '2024-12-18 15:11:34', '', '104', '0', 'نقدي', '1', '0', '3', '24', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150040', '0', '2024-12-18 15:11:34', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '190', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 15:10:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32032;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06337', '150040', '5', '14405', '1', '190', '190', '0', '', '1', '2024-12-18 15:11:35', '14405', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32032-1,','1','1','0','0','190','190','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 = 548087;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14405, '2024-12-18', 190, 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+190, 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-18', 190, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, 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 = '104', storedetaildate = '2024-12-18 15:11:35' WHERE storedetailid = '14404';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14405', '1', '1', '1', '150040', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '104', '2024-12-18 15:11:35','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '21725',  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 ('21535','190', '0', '1', 'اضافة فاتورة مبيعات', '150040', '21725', '2024-12-18 15:11:35', '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-18', 190, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, 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;
 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-18', 190, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 190, 340, 340
                    , 340, 340, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+190, netSellCostBuyPrice = netSellCostBuyPrice+340
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+340
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+340
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+340
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+340
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+340
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c9dbb5d04 and sellbillId = 150040 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c99f46a36
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9026,@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-18 15:09:51', '06762c99f46a36', '9026', '0.00', '1252', '0', '1', '1252.00', '1252', '0', '1252', '1', '2024-12-18 15:12:04', '', '101', '0', 'شدن محمد K205', '2', '1', '3', '79', 'شدن محمد K205', '5' ,'0','','','','','-1','0','0','0','0','0','1252','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1252', userid = '101' WHERE clientid = '9026';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9026','0.00','1252','0','اضافة فاتورة مبيعات','150041', '1252', '2024-12-18 15:12:04', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1252', '0', null, '0', null, null,'', '0','1','1','1252','1','2024-12-18 15:09:51','0','0');
UPDATE client SET  inUse = 0 where clientid = 9026;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35460;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07064', '150041', '5', '16065', '1', '220', '220', '0', '', '1', '2024-12-18 15:12:04', '16065', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35460-1,','1','1','0','0','220','220','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 = 548088;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16065, '2024-12-18', 220, 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+220, 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-18', 220, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, 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 = '6', userid = '101', storedetaildate = '2024-12-18 15:12:04' WHERE storedetailid = '16064';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16065', '1', '1', '1', '150041', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '101', '2024-12-18 15:12:04','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', '150041', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-18 15:12:04', '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 = 285, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 548089;
 INSERT INTO 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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 285, 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+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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 285, 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+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 = '25', userid = '101', storedetaildate = '2024-12-18 15:12:04' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150041', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '101', '2024-12-18 15:12:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34663;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1405', '150041', '14', '15685', '1', '600', '600', '0', '', '1', '2024-12-18 15:12:04', '15685', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34663-1,','1','1','0','0','600','600','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
        , lastbuyprice_withTax = 520, meanbuyprice_withTax = 520, lastbuyprice_withDiscountAndTax = 520
                where sellbilldetailid = 548090;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15685, '2024-12-18', 600, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 520, 520, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+520
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+520
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 600, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 520, 520, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+520
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+520
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:12:04' WHERE storedetailid = '15684';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15685', '1', '1', '1', '150041', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '101', '2024-12-18 15:12: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', '150041', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 15:12: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', '150041', '17', '10291', '1', '12', '12', '0', '', '1', '2024-12-18 15:12:04', '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 = 79 where clientid = 9026;
 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-18', 1252, 1005, 1005
                    , 1005, 1005, 1005, 1005
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1005, 955, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1252, sellCostBuyPrice =sellCostBuyPrice+1005
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1005, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1005
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1005, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1005
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1005
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1005
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+955
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (9026, '2024-12-18', 1252, 1005, 1005
                    , 1005, 1005, 1005, 1005
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1005, 955, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1252, sellCostBuyPrice =sellCostBuyPrice+1005
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1005, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1005
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1005, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1005
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1005
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1005
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+955
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1005, 1005
                    , 1005, 1005, 1005, 1005, 1005, 955)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1252, netSellCostBuyPrice = netSellCostBuyPrice+1005
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1005
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1005
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1005
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1005
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1005
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1005
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+955;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c99f46a36 and sellbillId = 150041 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:42:05";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:12:05", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:12:05', '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-18 11:44:17";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 15:14:17", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:14:17', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762c1f08f0c2
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3337,@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-18 14:37:04', '06762c1f08f0c2', '3337', '7.00', '1714', '0', '1', '1707.00', '1707', '0', '1707', '1', '2024-12-18 15:14:17', '', '75', '0', 'هاجر السبيلي f48', '2', '1', '3', '86', 'هاجر السبيلي f48', '7' ,'0','','','','','-1','0','0','0','0','0','1707','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1714', userid = '75' 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','7.00','1707','0','اضافة فاتورة مبيعات','150042', '1714', '2024-12-18 15:14:17', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1707', '0', null, '0', null, null,'', '0','1','1','1707','1','2024-12-18 14:37:04','0','0');
UPDATE client SET  inUse = 0 where clientid = 3337;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35723;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1461', '150042', '14', '15848', '1', '620', '620', '0', '', '1', '2024-12-18 15:14:17', '15848', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35723-1,','1','1','0','0','620','620','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 = 546, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 548093;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15848, '2024-12-18', 620, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 546, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+546
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 620, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 546, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+546
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:14:17' WHERE storedetailid = '15847';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15848', '1', '1', '1', '150042', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-18 15:14:17','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', '150042', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-18 15:14:18', '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 = 285, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 548094;
 INSERT INTO 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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 285, 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+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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 285, 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+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 = '24', userid = '75', storedetaildate = '2024-12-18 15:14:18' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150042', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '75', '2024-12-18 15:14:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150042', '1', '14553', '2', '225', '450', '0', '', '1', '2024-12-18 15:14:18', '14553', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32322-2,','1','1','0','0','225','450','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 = 548095;
 INSERT INTO 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-18', 450, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 450, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:14:18' WHERE storedetailid = '14552';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14553', '1', '2', '1', '150042', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '4', '75', '2024-12-18 15:14:18','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', '150042', '5', '16434', '1', '200', '200', '0', '', '1', '2024-12-18 15:14:18', '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 = 548096;
 INSERT INTO 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-18', 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-18', 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 = '9', userid = '75', storedetaildate = '2024-12-18 15:14:18' WHERE storedetailid = '16433';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16434', '1', '1', '1', '150042', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-18 15:14:18','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', '150042', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 15:14:18', '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', '150042', '17', '10291', '1', '17', '17', '0', '', '1', '2024-12-18 15:14:18', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','17','17','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 86 where clientid = 3337;
 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-18', 1707, 1420, 1420
                    , 1420, 1420, 1420, 1420
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,980, 976, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1707, sellCostBuyPrice =sellCostBuyPrice+1420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+980
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+976
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (3337, '2024-12-18', 1707, 1420, 1420
                    , 1420, 1420, 1420, 1420
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,980, 976, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1707, sellCostBuyPrice =sellCostBuyPrice+1420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1420
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+980
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+976
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1707, 1420, 1420
                    , 1420, 1420, 1420, 1420, 980, 976)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1707, netSellCostBuyPrice = netSellCostBuyPrice+1420
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1420
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1420
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1420
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1420
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1420
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+980
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+976;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762c1f08f0c2 and sellbillId = 150042 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:44:19";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 15:14:19", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:14: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-18 11:44:21";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:14:21", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:14:21', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762ca2580505
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(804,@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-18 15:12:05', '06762ca2580505', '804', '0.00', '939', '0', '1', '939.00', '939', '0', '939', '1', '2024-12-18 15:14:21', '', '101', '0', 'نفين الدمرداش K101', '2', '1', '3', '79', 'نفين الدمرداش K101', '4' ,'0','','','','','-1','0','0','0','0','0','939','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '939', userid = '101' WHERE clientid = '804';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('804','0.00','939','0','اضافة فاتورة مبيعات','150043', '939', '2024-12-18 15:14:21', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '939', '0', null, '0', null, null,'', '0','1','1','939','1','2024-12-18 15:12:05','0','0');
UPDATE client SET  inUse = 0 where clientid = 804;
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', '150043', '1', '16277', '1', '650', '650', '0', '', '1', '2024-12-18 15:14:21', '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 = 548099;
 INSERT INTO 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-18', 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-18', 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 = '51', userid = '101', storedetaildate = '2024-12-18 15:14:21' WHERE storedetailid = '16276';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16277', '1', '1', '1', '150043', 'اضافة فاتورة مبيعات', 'sellbillController.php', '52', '51', '101', '2024-12-18 15:14:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33185;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3104', '150043', '1', '14998', '1', '260', '260', '0', '', '1', '2024-12-18 15:14:21', '14998', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33185-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
        
                where sellbilldetailid = 548100;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14998, '2024-12-18', 260, 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+260, 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-18', 260, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 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+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:14:21' WHERE storedetailid = '14997';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14998', '1', '1', '1', '150043', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '101', '2024-12-18 15:14: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', '150043', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 15:14:21', '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', '150043', '17', '10291', '1', '9', '9', '0', '', '1', '2024-12-18 15:14:21', '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 = 79 where clientid = 804;
 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-18', 939, 750, 750
                    , 749, 750, 747, 746.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 548, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+939, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+750, sellCostMeanBuyPrice = sellCostMeanBuyPrice+749
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+750, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+747
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+746.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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (804, '2024-12-18', 939, 750, 750
                    , 749, 750, 747, 746.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 548, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+939, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+750, sellCostMeanBuyPrice = sellCostMeanBuyPrice+749
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+750, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+747
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+746.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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 939, 750, 750
                    , 749, 750, 747, 746.67, 550, 548)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+939, netSellCostBuyPrice = netSellCostBuyPrice+750
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+750
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+749
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+750
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+747
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+746.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+550
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+548;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762ca2580505 and sellbillId = 150043 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:44:21";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:14:22", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:14:22', '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-18 11:45:28";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 15:15:28", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:15: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 06762caab402a2
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7280,@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-18 15:14:19', '06762caab402a2', '7280', '0.00', '1000', '0', '1', '1000.00', '1000', '0', '1000', '1', '2024-12-18 15:15:28', '', '75', '0', 'زينب عصام F252', '2', '1', '3', '86', 'زينب عصام F252', '4' ,'0','','','','','-1','0','0','0','0','0','1000','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1000', userid = '75' WHERE clientid = '7280';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7280','0.00','1000','0','اضافة فاتورة مبيعات','150044', '1000', '2024-12-18 15:15:28', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1000', '0', null, '0', null, null,'', '0','1','1','1000','1','2024-12-18 15:14:19','0','0');
UPDATE client SET  inUse = 0 where clientid = 7280;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35936;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07192', '150044', '5', '16310', '1', '620', '620', '0', '', '1', '2024-12-18 15:15:29', '16310', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35936-1,','1','1','0','0','620','620','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 = 550, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 548103;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16310, '2024-12-18', 620, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 550, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 620, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:15:29' WHERE storedetailid = '16309';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16310', '1', '1', '1', '150044', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-18 15:15:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34935;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('290','06955', '150044', '5', '15858', '1', '350', '350', '0', '', '1', '2024-12-18 15:15:29', '15858', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34935-1,','1','1','0','0','350','350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 290.00 , meanbuyprice = 290.00, lastbuyprice_withDiscount = 290.00, meanbuyprice_withDiscount = 290.00
        , lastbuyprice_withTax = 290, meanbuyprice_withTax = 290, lastbuyprice_withDiscountAndTax = 290
                where sellbilldetailid = 548104;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15858, '2024-12-18', 350, 290, 290
                    , 290, 290, 290, 290
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 290, 290, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+290
                            , 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
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 350, 290, 290
                    , 290, 290, 290, 290
                    , 0, 0, 0, 0
                    , 0, 0, 0, 290, 290, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+290
                            , 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;
UPDATE storedetail SET  productquantity = '5', userid = '75', storedetaildate = '2024-12-18 15:15:29' WHERE storedetailid = '15857';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15858', '1', '1', '1', '150044', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-18 15:15: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', '150044', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 15:15: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', '150044', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-18 15:15:29', '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 = 7280;
 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-18', 1000, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1000, 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 (7280, '2024-12-18', 1000, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1000, 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, 1000, 840, 840
                    , 840, 840, 840, 840, 840, 840)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1000, 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 06762caab402a2 and sellbillId = 150044 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:45:29";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 15:15:29", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:15: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-18 11:45:43";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:15:43", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:15:43', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762caae27859
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1911,@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-18 15:14:22', '06762caae27859', '1911', '479.00', '706', '0', '1', '227.00', '227', '0', '227', '1', '2024-12-18 15:15:43', '', '101', '0', 'جيجي المقدم73', '2', '1', '3', '79', 'جيجي المقدم73', '2' ,'0','','','','','-1','0','0','0','0','0','227','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '706', userid = '101' WHERE clientid = '1911';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1911','479.00','227','0','اضافة فاتورة مبيعات','150045', '706', '2024-12-18 15:15:43', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '227', '0', null, '0', null, null,'', '0','1','1','227','1','2024-12-18 15:14:22','0','0');
UPDATE client SET  inUse = 0 where clientid = 1911;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 23781;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3009', '150045', '1', '10136', '1', '225', '225', '0', '', '1', '2024-12-18 15:15:43', '10136', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','23781-1,','1','1','0','0','225','225','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 225.00 , meanbuyprice = 237.00, lastbuyprice_withDiscount = 225.00, meanbuyprice_withDiscount = 237.00
        
                where sellbilldetailid = 548107;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10136, '2024-12-18', 225, 225, 225
                    , 237, 225, 237, 217.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+225, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+237
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+237
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+217.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-18', 225, 225, 225
                    , 237, 225, 237, 217.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+225, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+237
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+237
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+217.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 = '25', userid = '101', storedetaildate = '2024-12-18 15:15:43' WHERE storedetailid = '10135';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10136', '1', '1', '1', '150045', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '101', '2024-12-18 15:15: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 ('0','10291', '150045', '17', '10291', '1', '2', '2', '0', '', '1', '2024-12-18 15:15:43', '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 = 79 where clientid = 1911;
 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-18', 227, 225, 225
                    , 237, 225, 237, 217.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+227, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+237
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+237
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+217.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 (1911, '2024-12-18', 227, 225, 225
                    , 237, 225, 237, 217.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+227, sellCostBuyPrice =sellCostBuyPrice+225
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+225, sellCostMeanBuyPrice = sellCostMeanBuyPrice+237
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+225, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+237
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+217.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, 227, 225, 225
                    , 237, 225, 237, 217.5, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+227, netSellCostBuyPrice = netSellCostBuyPrice+225
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+225
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+237
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+225
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+237
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+217.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762caae27859 and sellbillId = 150045 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:45:43";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:15:43", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:15:43', '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-18 11:46:00";
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-18',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-18 11:46:01";
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-18 11:46:17";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 15:16:17", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 15:16:17', '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-18 11:46:18";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:46:24";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 15:16:24", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:16:24', '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-18 11:46:31";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 15:16:31", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:16:31', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.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 ('روناء اسيوط 99' , '', '', '01023160060', '0', '', '0', '2024-12-18 15:17:06', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-18','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10742', '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 ('10742','0','0','0','إضافة عميل جديد','10742', '0', '2024-12-18 15:17:06', '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-18 15:17:07');
UPDATE client SET clientname = 'روناء اسيوط 99', clientaddress = '', clientphone = '', clientmobile = '01023160060', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-18', 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='12551',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10742';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:47:36";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 15:17:36", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:17:36', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150045');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:47:46";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 15:17:46", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:17: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 06762caf1e152a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10742,@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-18 15:15:29', '06762caf1e152a', '10742', '0.00', '636', '0', '1', '636.00', '636', '0', '636', '1', '2024-12-18 15:17:46', '', '75', '0', 'روناء اسيوط 99', '2', '1', '3', '85', 'روناء اسيوط 99', '3' ,'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-18','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '636', userid = '75' 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','0.00','636','0','اضافة فاتورة مبيعات','150046', '636', '2024-12-18 15:17:46', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '636', '0', null, '0', null, null,'', '0','1','1','636','1','2024-12-18 15:15:29','0','0');
UPDATE client SET  inUse = 0 where clientid = 10742;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35722;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1379', '150046', '14', '15622', '1', '610', '610', '0', '', '1', '2024-12-18 15:17:46', '15622', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35722-1,','1','1','0','0','610','610','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 501.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 501.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 509, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 548109;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15622, '2024-12-18', 610, 500, 500
                    , 501, 500, 501, 425.29
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 509, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+501
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+501
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+509
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 610, 500, 500
                    , 501, 500, 501, 425.29
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 509, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+501
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+501
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+509
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:17:46' WHERE storedetailid = '15621';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15622', '1', '1', '1', '150046', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '75', '2024-12-18 15:17: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 ('20','50235', '150046', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 15:17:46', '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', '150046', '17', '10291', '1', '6', '6', '0', '', '1', '2024-12-18 15:17:46', '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 = 85 where clientid = 10742;
 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-18', 636, 500, 500
                    , 501, 500, 501, 425.29
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,500, 509, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+636, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+501
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+501
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+509
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (10742, '2024-12-18', 636, 500, 500
                    , 501, 500, 501, 425.29
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,500, 509, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+636, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+501
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+501
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+425.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+509
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 500, 500
                    , 501, 500, 501, 425.29, 500, 509)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+636, netSellCostBuyPrice = netSellCostBuyPrice+500
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+500
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+501
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+500
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+501
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+425.29
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+500
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+509;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762caf1e152a and sellbillId = 150046 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:47:46";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 15:17:46", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:17:46', '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-18 11:47:48";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 15:17:48", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:17:48', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150043');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:47:58";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 15:17:58", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:17:58', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150041');
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-18 11:48:09";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 15:18:09", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:18:09', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150039');
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-18 11:48:12";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:18:13", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 15:18:13', '77', '', '192.168.1.21', '', '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-18 11:48:13";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:48:22";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 15:18:22", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:18:23', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150038');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:48:58";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:18:58", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:18:58', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:49:07";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 15:19:07", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:19:07', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762cb7b1fd49
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9085,@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-18 15:17:47', '06762cb7b1fd49', '9085', '556.00', '970', '0', '1', '414.00', '414', '0', '414', '1', '2024-12-18 15:19:07', '', '75', '0', 'هبة رضا m222', '2', '1', '3', '100', 'هبة رضا m222', '2' ,'0','','','','','-1','0','0','0','0','0','414','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '970', userid = '75' WHERE clientid = '9085';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9085','556.00','414','0','اضافة فاتورة مبيعات','150047', '970', '2024-12-18 15:19:07', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '414', '0', null, '0', null, null,'', '0','1','1','414','1','2024-12-18 15:17:47','0','0');
UPDATE client SET  inUse = 0 where clientid = 9085;
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', '150047', '14', '16167', '1', '410', '410', '0', '', '1', '2024-12-18 15:19:07', '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 = 548112;
 INSERT INTO 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-18', 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-18', 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 = '17', userid = '75', storedetaildate = '2024-12-18 15:19:07' WHERE storedetailid = '16166';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16167', '1', '1', '1', '150047', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '75', '2024-12-18 15:19:07','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', '150047', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-18 15:19:07', '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 = 100 where clientid = 9085;
 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-18', 414, 350, 350
                    , 349, 350, 349, 347
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 349, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+414, 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 (9085, '2024-12-18', 414, 350, 350
                    , 349, 350, 349, 347
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 349, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+414, 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, 414, 350, 350
                    , 349, 350, 349, 347, 350, 349)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+414, 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 06762cb7b1fd49 and sellbillId = 150047 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:49:08";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 15:19:08", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:19:08', '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-18 11:49:20";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:19:20", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:19:20', '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-18 11:49:46";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:19:46", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:19:46', '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-18 11:50:45";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:20:45", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:20:45', '101', 'delete', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=delete&sellbillid=147492&action=0');

-- ----------------------------------------------------------------------------------------------------
-- bill delete start - sellbill with id = 147492
-- ----------------------------------------------------------------------------------------------------

BEGIN;
UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 147492;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 15:20:45', userid = '75',delbyuserid = '101', conditions = '1'  ,billReservation= 0,billReservationDate='0000-00-00'  WHERE sellbillid = '147492';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-2 where id = 35739;
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 = 539005;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16222, '2024-12-18', 1100, 900, 900
                    , 900, 900, 900, 900
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 900, 900, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1100, sellCostBuyPrice =sellCostBuyPrice-900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-900, sellCostMeanBuyPrice = sellCostMeanBuyPrice-900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-900
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-900
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-900
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-900
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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-18', 1100, 900, 900
                    , 900, 900, 900, 900
                    , 0, 0, 0, 0
                    , 0, 0, 0, 900, 900, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1100, sellCostBuyPrice =sellCostBuyPrice-900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-900, sellCostMeanBuyPrice = sellCostMeanBuyPrice-900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-900
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-900
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-900
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-900
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 15:20:45' WHERE storedetailid = '16221';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16222', '1', '2', '0', '147492', 'حذف فاتورة مبيعات', 'sellbillController.php', '8', '10', '101', '2024-12-18 15:20:45','0','0');
CALL clientInUse(6673,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '101' WHERE clientid = '6673';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6673','1131.00','1131.00','1','حذف فاتورة مبيعات','147492', '0', '2024-12-18 15:20:45', '101', 'sellbillController.php', 'حذف فاتورة مبيعات', '1131', '0', null, '0', null, null,'', '0','1','1','1131','1','2024-12-02 16:53:27','0','0');
UPDATE client SET  inUse = 0 where clientid = 6673;
 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-18', 1131, 900, 900
                    , 900, 900, 900, 900
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,900, 900, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1131, sellCostBuyPrice =sellCostBuyPrice-900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-900, sellCostMeanBuyPrice = sellCostMeanBuyPrice-900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-900
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-900
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-900
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-900
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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 (6673, '2024-12-18', 1131, 900, 900
                    , 900, 900, 900, 900
                    , 0, 0, 0, 0
                    , 0, 0, 0, 900, 900, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1131, sellCostBuyPrice =sellCostBuyPrice-900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-900, sellCostMeanBuyPrice = sellCostMeanBuyPrice-900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-900
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-900
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-900
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-900
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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, 1131, 900, 900
                    , 900, 900, 900, 900, 900, 900)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-1131, netSellCostBuyPrice = netSellCostBuyPrice-900
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-900
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-900
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-900
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-900
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-900
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-900
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-900;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill delete end - sellbill with id = 147492
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:50:45";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:20:45", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:20:45', '101', 'sucess', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:50:47";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:20:47", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:20:47', '101', 'show', '192.168.1.27', '', '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 ('H1676','','14','410','480', '480','480', '2024-12-18', '0', '77', '1', 'H1676', '0', '0', '0', '0', '0', '410','410','410','410','410','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','410','410','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16472, 1,'2024-12-18 15:21:15',77)
                ON DUPLICATE KEY UPDATE productid = 16472, edited = 1, sysdate = '2024-12-18 15:21: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', '16472', '1', '2024-12-18', '77', '0','1647201','480','480','480','410','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16472', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16472', '1', '0', '0', '16472', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:51:21";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:21:21", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:21:21', '77', 'add', '192.168.1.21', '', '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 ('06762cbc2a23ed', '2024-12-18 15:18:58', '27', '379275.00', '385425', '0', '0', '6150',  '6150', '0', '6150', '1', '2024-12-18 15:21: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 ('H1676', '14130', '14', '16472', '15', '410', '6150', '0', '', '2024-12-18 15:21:21', '16472','','','0','0','0','0','0',null,'410','6150','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-18 15:18:58', 1, 16472, 0, 0
                    , 410, 15, 0, 0, 77, '2024-12-18 15:21:21')
                ON DUPLICATE KEY UPDATE buyprice = 410,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:21:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16472', '410', '15', '0', 'buyBillController.php', '32696', '', '0', '0');
UPDATE product SET  productBuyPrice = "410" WHERE productId = 16472 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32696 ;
UPDATE product SET productName = 'H1676', productDescription = '', productCatId = '14', productBuyPrice = '410.00', productSellAllPrice = '480.00', productSellUnitPrice = '480.00', productSellHalfPrice = '480.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1676',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '410',lastbuyprice_withDiscount = '410',meanbuyprice = '410',meanbuyprice_withDiscount = '410' , productbuypricereal = '410.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='410',meanbuyprice_withTax='410',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='410'  WHERE productId = '16472';
UPDATE buybilldetail SET  lastbuyprice = 410 , meanbuyprice = 410, lastbuyprice_withDiscount = 410, meanbuyprice_withDiscount = 410
        , lastbuyprice_withTax = 410, meanbuyprice_withTax = 410, lastbuyprice_withDiscountAndTax = 410
                where buybilldetailid = 32696;
UPDATE productunit SET proUnitBuyPrice  = 410 * productnumber WHERE productid = 16472;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16471';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16472', '1', '15', '0', '14130', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 15:18:58','0','0');
UPDATE supplier SET  suppliercurrentDebt = '385425',suppliercurrentDebtInCurrency= '385425' , userid = '77', supplierdate = '2024-12-18 15:21:21'   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', '379275.00', '6150', '0', 'اضافة فاتورة مشتريات', '14130', '385425', '2024-12-18 15:18:58', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','6150','1','379275','6150','385425','0');
update buybill set dailyentryid='0,' where buybillid=14130;
COMMIT;
UPDATE product SET overAllAveragePrice = 410 WHERE productId = 16472;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:51:22";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:21:22", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:21:22', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14130');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:51:56";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:21:56", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:21:56', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:52:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:22:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:22:05', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762ca079093b
-- ----------------------------------------------------------------------------------------------------

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-18 15:11:35', '06762ca079093b', '1', '0.00', '0', '0', '1', '220.00', '220', '220', '0', '1', '2024-12-18 15:22:05', '', '104', '0', 'نقدي', '1', '0', '3', '95', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150048', '0', '2024-12-18 15:22:05', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '220', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 15:11:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33241;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3113', '150048', '1', '15036', '1', '220', '220', '0', '', '1', '2024-12-18 15:22:05', '15036', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33241-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
        
                where sellbilldetailid = 548114;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15036, '2024-12-18', 220, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 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+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 220, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 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+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:22:05' WHERE storedetailid = '15035';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15036', '1', '1', '1', '150048', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '104', '2024-12-18 15:22:05','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '21945',  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 ('21725','220', '0', '1', 'اضافة فاتورة مبيعات', '150048', '21945', '2024-12-18 15:22:05', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 95 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-18', 220, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 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+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 220, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 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+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 170, 170
                    , 170, 170, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+220, netSellCostBuyPrice = netSellCostBuyPrice+170
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+170
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+170
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+170
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+170
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+170
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762ca079093b and sellbillId = 150048 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:52:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:22:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:22:06', '104', 'addsellBill', '192.168.1.13', '', '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 ('H1689','','14','370','450', '450','450', '2024-12-18', '0', '77', '1', 'H1689', '0', '0', '0', '0', '0', '370','370','370','370','370','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','370','370','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16473, 1,'2024-12-18 15:23:33',77)
                ON DUPLICATE KEY UPDATE productid = 16473, edited = 1, sysdate = '2024-12-18 15:23:33', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16473', '1', '2024-12-18', '77', '0','1647301','450','450','450','370','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16473', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16473', '1', '0', '0', '16473', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:53:49";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:23:49", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:23:49', '77', 'add', '192.168.1.21', '', '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 ('06762cc743ae55', '2024-12-18 15:21:56', '9', '289250.00', '292950', '0', '0', '3700',  '3700', '0', '3700', '1', '2024-12-18 15:23: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 ('H1689', '14131', '14', '16473', '10', '370', '3700', '0', '', '2024-12-18 15:23:49', '16473','','','0','0','0','0','0',null,'370','3700','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-18 15:21:56', 1, 16473, 0, 0
                    , 370, 10, 0, 0, 77, '2024-12-18 15:23:49')
                ON DUPLICATE KEY UPDATE buyprice = 370,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:23:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16473', '370', '10', '0', 'buyBillController.php', '32697', '', '0', '0');
UPDATE product SET  productBuyPrice = "370" WHERE productId = 16473 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32697 ;
UPDATE product SET productName = 'H1689', productDescription = '', productCatId = '14', productBuyPrice = '370.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1689',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '370',lastbuyprice_withDiscount = '370',meanbuyprice = '370',meanbuyprice_withDiscount = '370' , productbuypricereal = '370.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='370',meanbuyprice_withTax='370',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='370'  WHERE productId = '16473';
UPDATE buybilldetail SET  lastbuyprice = 370 , meanbuyprice = 370, lastbuyprice_withDiscount = 370, meanbuyprice_withDiscount = 370
        , lastbuyprice_withTax = 370, meanbuyprice_withTax = 370, lastbuyprice_withDiscountAndTax = 370
                where buybilldetailid = 32697;
UPDATE productunit SET proUnitBuyPrice  = 370 * productnumber WHERE productid = 16473;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16472';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16473', '1', '10', '0', '14131', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-18 15:21:56','0','0');
UPDATE supplier SET  suppliercurrentDebt = '292950',suppliercurrentDebtInCurrency= '292950' , userid = '77', supplierdate = '2024-12-18 15:23:49'   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', '289250.00', '3700', '0', 'اضافة فاتورة مشتريات', '14131', '292950', '2024-12-18 15:21:56', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','3700','1','289250','3700','292950','0');
update buybill set dailyentryid='0,' where buybillid=14131;
COMMIT;
UPDATE product SET overAllAveragePrice = 370 WHERE productId = 16473;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:53:50";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:23:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:23:50', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14131');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:54:08";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:24:08", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 15:24:08', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:54:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:24:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:24:18', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762cc7e5409b
-- ----------------------------------------------------------------------------------------------------

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-18 15:22:06', '06762cc7e5409b', '1', '0.00', '0', '0', '1', '610.00', '610', '610', '0', '1', '2024-12-18 15:24:19', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'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-18','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','اضافة فاتورة مبيعات','150049', '0', '2024-12-18 15:24:19', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '610', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 15:22:06','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', '150049', '5', '16316', '1', '300', '300', '0', '', '1', '2024-12-18 15:24:19', '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 = 548115;
 INSERT INTO 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-18', 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-18', 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 = '19', userid = '104', storedetaildate = '2024-12-18 15:24:19' WHERE storedetailid = '16315';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16316', '1', '1', '1', '150049', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '104', '2024-12-18 15:24:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35926;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07205', '150049', '5', '16302', '1', '310', '310', '0', '', '1', '2024-12-18 15:24:19', '16302', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35926-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 = 250, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 548116;
 INSERT INTO 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-18', 310, 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+310, 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-18', 310, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 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+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 = '8', userid = '104', storedetaildate = '2024-12-18 15:24:19' WHERE storedetailid = '16301';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16302', '1', '1', '1', '150049', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-18 15:24:19','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22555',  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 ('21945','610', '0', '1', 'اضافة فاتورة مبيعات', '150049', '22555', '2024-12-18 15:24:19', '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-18', 610, 475, 475
                    , 475, 475, 475, 475
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,475, 475, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+475
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+475
                            , 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;
 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-18', 610, 475, 475
                    , 475, 475, 475, 475
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,475, 475, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+610, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+475
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+475
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 610, 475, 475
                    , 475, 475, 475, 475, 475, 475)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+610, netSellCostBuyPrice = netSellCostBuyPrice+475
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+475
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+475
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+475
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+475
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+475
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+475
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+475;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762cc7e5409b and sellbillId = 150049 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:54:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:24:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:24:19', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:54:19";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:24:19", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 15:24:19', '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-18 11:55:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:25:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:25:34', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:56:32";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:26:32", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:26:32', '101', 'showDetail', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149812');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:56:59";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:26:59", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:26:59', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247328
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3899,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 15:26:59', userid = '2' WHERE clientid = '3899';
UPDATE client SET  inUse = 0 where clientid = 3899;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3899','606.00','606','1','ايصال تحصيل (( قبض من عميل ))','247328', '0', '2024-12-18 15:04:51', '2', 'clientPayedDeptController.php', '   ', '606', '0', null, '0', null, null,'', '-1','1','1','606','1','','3504','0');
UPDATE save SET  savecurrentvalue = '204495.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('203889.50','606', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247343', '204495.5', '2024-12-18 15:26:59', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '606', '606', '2024-12-18', '2', '0', '0', '2024-12-18 15:27:00','اضافة ايصال سداد للعميل ام جني الشرقية t61','1','0','0','0','247343','clientPayedDeptController.php?do=show&id=247343');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122150', '-1', '606', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '606', 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 ('122150', '-1', '606', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-606', 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 = '3899', clientdebtchangebefore = '606.000', clientdebtchangeamount = '606.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247328', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 15:04:51', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '606.00',discount='', reciptid='0', dailyentryid = '122150',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='606',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247343';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247328 -clientdebtchangeId = 247343
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:57:00";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:27:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:27: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-18 11:57:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:27:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:27:01', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:57:20";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:27:20", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:27:20', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:57:42";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:27:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:27:42', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247344
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10298,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '2' , clientdate = '2024-12-18 15:27:42', userid = '2' WHERE clientid = '10298';
UPDATE client SET  inUse = 0 where clientid = 10298;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10298','1232.00','1230','1','ايصال تحصيل (( قبض من عميل ))','247344', '2', '2024-12-18 15:27:01', '2', 'clientPayedDeptController.php', '   ', '1230', '0', null, '0', null, null,'', '-1','1','1','1230','1','','3505','0');
UPDATE save SET  savecurrentvalue = '205725.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('204495.50','1230', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247344', '205725.5', '2024-12-18 15:27:42', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1230', '1230', '2024-12-18', '2', '0', '0', '2024-12-18 15:27:42','اضافة ايصال سداد للعميل امنية عبد الهادي 73','1','0','0','0','247344','clientPayedDeptController.php?do=show&id=247344');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122151', '-1', '1230', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1230', 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 ('122151', '11276', '1230', '','0');
UPDATE accountstree SET name = 'امنية عبد الهادي 73', customName = 'امنية عبد الهادي 73', customNameEn = 'امنية عبد الهادي 73', nameEn = 'امنية عبد الهادي 73', parent = '58', accountNature = '0', theValue = '-3880', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-11-06 16:46:13' WHERE id = '11276';
UPDATE clientdebtchange SET clientid = '10298', clientdebtchangebefore = '1232.000', clientdebtchangeamount = '1230.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247344', clientdebtchangeafter = '2.000', clientdebtchangedate = '2024-12-18 15:27:01', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1230.00',discount='', reciptid='0', dailyentryid = '122151',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1230',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247344';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:57:43";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:27:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:27: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-18 11:57:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:27:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:27:51', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762cda5a1fa9
-- ----------------------------------------------------------------------------------------------------

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-18 15:27:01', '06762cda5a1fa9', '1', '0.00', '0', '0', '1', '255', '255', '-255', '0', '1', '2024-12-18 15:27:51', '', '104', '0', 'نقدي','1', '0', '5', '6', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-255','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','اضافة فاتورة مردوات مبيعات','16816', '0', '2024-12-18 15:27:51', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '255', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 15:27:01','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 ('270.00', 'R2922', '16816', '1', '14396', '1', '255', '255', '0', '', '1', '0', '14396', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','255','255','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 270.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 270.00, meanbuyprice_withDiscount = 270.00
        
                where returnsellbilldetailid = 21998;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14396, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 255, 270, 270, 270
                    , 270, 270, 270, 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+255, returnSellCostBuyPrice = returnSellCostBuyPrice+270, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+270
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+270, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+270
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+270
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+270
                            , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 255, 270, 270, 270
                    , 270, 270, 270, 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+255, returnSellCostBuyPrice = returnSellCostBuyPrice+270, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+270
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+270, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+270
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+270
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+270
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-18 15:27:51' WHERE storedetailid = '14395';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14396', '1', '1', '0', '16816', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '2', '3', '104', '2024-12-18 15:27:51','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22300',  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 ('22555','-255', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16816', '22300', '2024-12-18 15:27:51', '104',  '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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 255, 270, 270, 270
                    , 270, 270, 270 ,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+255, returnSellCostBuyPrice = returnSellCostBuyPrice+270, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+270
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+270, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+270
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+270
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+270
                            , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 255, 270, 270, 270
                    , 270, 270, 270 ,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+255, returnSellCostBuyPrice = returnSellCostBuyPrice+270, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+270
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+270, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+270
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+270
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+270
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -255, -270, -270
                    , -270, -270, -270, -270, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-255, 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 06762cda5a1fa9 and sellbillId = 16816 and returnsellbillId = 16816
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:57:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:27:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:27:52', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:58:00";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:28:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:28:00', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247345
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2856,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 15:28:00', userid = '2' WHERE clientid = '2856';
UPDATE client SET  inUse = 0 where clientid = 2856;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2856','1808.00','1808','1','ايصال تحصيل (( قبض من عميل ))','247345', '0', '2024-12-18 15:27:43', '2', 'clientPayedDeptController.php', '   ', '1808', '0', null, '0', null, null,'', '-1','1','1','1808','1','','3506','0');
UPDATE save SET  savecurrentvalue = '207533.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('205725.50','1808', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247346', '207533.5', '2024-12-18 15:28:00', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1808', '1808', '2024-12-18', '2', '0', '0', '2024-12-18 15:28:00','اضافة ايصال سداد للعميل رشا سمير t77','1','0','0','0','247346','clientPayedDeptController.php?do=show&id=247346');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122152', '-1', '1808', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1808', 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 ('122152', '-1', '1808', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1808', 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 = '2856', clientdebtchangebefore = '1808.000', clientdebtchangeamount = '1808.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247345', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 15:27:43', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1808.00',discount='', reciptid='0', dailyentryid = '122152',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1808',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247346';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247345 -clientdebtchangeId = 247346
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762cb001519e
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5242,@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-18 15:15:44', '06762cb001519e', '5242', '0.00', '616', '0', '1', '616.00', '616', '0', '616', '1', '2024-12-18 15:28:18', '', '101', '0', 'يارا طارق ', '2', '1', '3', '88', 'يارا طارق ', '3' ,'0','','','','','-1','0','0','0','0','0','616','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '616', userid = '101' WHERE clientid = '5242';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5242','0.00','616','0','اضافة فاتورة مبيعات','150050', '616', '2024-12-18 15:28:18', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '616', '0', null, '0', null, null,'', '0','1','1','616','1','2024-12-18 15:15:44','0','0');
UPDATE client SET  inUse = 0 where clientid = 5242;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34735;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1356', '150050', '14', '15475', '1', '590', '590', '0', '', '1', '2024-12-18 15:28:18', '15475', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34735-1,','1','1','0','0','590','590','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 = 591, lastbuyprice_withDiscountAndTax = 575
                where sellbilldetailid = 548117;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15475, '2024-12-18', 590, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 575, 591, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+590, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+591
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 590, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0, 575, 591, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+590, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+591
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:28:18' WHERE storedetailid = '15474';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15475', '1', '1', '1', '150050', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '101', '2024-12-18 15:28:18','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', '150050', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 15:28:18', '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', '150050', '17', '10291', '1', '6', '6', '0', '', '1', '2024-12-18 15:28:18', '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 = 5242;
 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-18', 616, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,575, 591, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+616, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+591
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (5242, '2024-12-18', 616, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,575, 591, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+616, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+591
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 616, 575, 575
                    , 575, 575, 575, 575, 575, 591)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+616, netSellCostBuyPrice = netSellCostBuyPrice+575
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+575
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+575
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+575
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+575
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+575
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+575
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+591;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762cb001519e and sellbillId = 150050 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:58:18";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:28:18", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:28: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-18 11:58:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:28:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:28:21', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:58:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:28:22", deviceType = "DESKTOP" WHERE userid = 104;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:58:22";
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:28:22', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:28:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:28:22', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247347
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9683,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 15:28:22', userid = '2' WHERE clientid = '9683';
UPDATE client SET  inUse = 0 where clientid = 9683;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9683','404.00','404','1','ايصال تحصيل (( قبض من عميل ))','247347', '0', '2024-12-18 15:28:01', '2', 'clientPayedDeptController.php', '   ', '404', '0', null, '0', null, null,'', '-1','1','1','404','1','','3507','0');
UPDATE save SET  savecurrentvalue = '207937.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('207533.50','404', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247348', '207937.5', '2024-12-18 15:28:22', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '404', '404', '2024-12-18', '2', '0', '0', '2024-12-18 15:28:22','اضافة ايصال سداد للعميل ياسمين عادل ','1','0','0','0','247348','clientPayedDeptController.php?do=show&id=247348');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122153', '-1', '404', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '404', 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 ('122153', '-1', '404', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-404', 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 = '9683', clientdebtchangebefore = '404.000', clientdebtchangeamount = '404.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247347', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 15:28:01', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '404.00',discount='', reciptid='0', dailyentryid = '122153',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='404',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247348';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247347 -clientdebtchangeId = 247348
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:58:23";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:28:23", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:28:23', '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 ('7311','','5','210','260', '260','260', '2024-12-18', '0', '77', '1', '20250', '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 (16474, 1,'2024-12-18 15:28:24',77)
                ON DUPLICATE KEY UPDATE productid = 16474, edited = 1, sysdate = '2024-12-18 15:28: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', '16474', '1', '2024-12-18', '77', '0','1647401','260','260','260','210','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16474', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16474', '1', '0', '0', '16474', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:58:44";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:28:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:28:44', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247349
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10740,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 15:28:44', userid = '2' WHERE clientid = '10740';
UPDATE client SET  inUse = 0 where clientid = 10740;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10740','222.00','222','1','ايصال تحصيل (( قبض من عميل ))','247349', '0', '2024-12-18 15:28:23', '2', 'clientPayedDeptController.php', '   ', '222', '0', null, '0', null, null,'', '-1','1','1','222','1','','3508','0');
UPDATE save SET  savecurrentvalue = '208159.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('207937.50','222', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247349', '208159.5', '2024-12-18 15:28:44', '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-18', '2', '0', '0', '2024-12-18 15:28:44','اضافة ايصال سداد للعميل ادم المهندسين','1','0','0','0','247349','clientPayedDeptController.php?do=show&id=247349');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122154', '-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 ('122154', '12549', '222', '','0');
UPDATE accountstree SET name = 'ادم المهندسين', customName = 'ادم المهندسين', customNameEn = 'ادم المهندسين', nameEn = 'ادم المهندسين', parent = '58', accountNature = '0', theValue = '-222', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '104', del = '0', sysdate = '2024-12-18 14:39:54' WHERE id = '12549';
UPDATE clientdebtchange SET clientid = '10740', clientdebtchangebefore = '222.000', clientdebtchangeamount = '222.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247349', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 15:28:23', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '222.00',discount='', reciptid='0', dailyentryid = '122154',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='222',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247349';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:58:45";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:28:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:28:45', '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 ('7313','','5','210','260', '260','260', '2024-12-18', '0', '77', '1', '07313', '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 (16475, 1,'2024-12-18 15:28:59',77)
                ON DUPLICATE KEY UPDATE productid = 16475, edited = 1, sysdate = '2024-12-18 15:28: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', '16475', '1', '2024-12-18', '77', '0','1647501','260','260','260','210','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16475', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16475', '1', '0', '0', '16475', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:59:18";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:29:18", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:29:18', '77', 'add', '192.168.1.21', '', '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 ('06762cdb8a6565', '2024-12-18 15:27:20', '80', '238400.00', '261725', '0', '0', '23325',  '23325', '0', '23325', '1', '2024-12-18 15:29:18', '', '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 ('R3336', '14132', '1', '16417', '15', '165', '2475', '0', '', '2024-12-18 15:29:18', '16417','','','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-18 15:27:20', 1, 16417, 0, 0
                    , 165, 15, 0, 0, 77, '2024-12-18 15:29:18')
                ON DUPLICATE KEY UPDATE buyprice = 165,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:29:18' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16417', '165', '15', '0', 'buyBillController.php', '32698', '', '0', '0');
UPDATE product SET  productBuyPrice = "165" WHERE productId = 16417 ;
UPDATE buybilldetail SET  quantitybefore = 6 WHERE buybilldetailid = 32698 ;
UPDATE product SET productName = 'R3336', productDescription = '', productCatId = '1', productBuyPrice = '165.00', productSellAllPrice = '220.00', productSellUnitPrice = '220.00', productSellHalfPrice = '220.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3336',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '165',lastbuyprice_withDiscount = '165',meanbuyprice = '165',meanbuyprice_withDiscount = '165' , productbuypricereal = '165.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='165',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='165',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 = '16417';
UPDATE buybilldetail SET  lastbuyprice = 165 , meanbuyprice = 165, lastbuyprice_withDiscount = 165, meanbuyprice_withDiscount = 165
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 165, lastbuyprice_withDiscountAndTax = 165
                where buybilldetailid = 32698;
UPDATE productunit SET proUnitBuyPrice  = 165 * productnumber WHERE productid = 16417;
UPDATE storedetail SET  productquantity = '21', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16416';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16417', '1', '15', '0', '14132', 'اضافة فاتورة مشتريات', 'buyBillController.php', '6', '21', '77', '2024-12-18 15:27: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 ('20250', '14132', '5', '16474', '15', '210', '3150', '0', '', '2024-12-18 15:29:18', '16474','','','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-18 15:27:20', 1, 16474, 0, 0
                    , 210, 15, 0, 0, 77, '2024-12-18 15:29:18')
                ON DUPLICATE KEY UPDATE buyprice = 210,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:29:18' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16474', '210', '15', '0', 'buyBillController.php', '32699', '', '0', '0');
UPDATE product SET  productBuyPrice = "210" WHERE productId = 16474 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32699 ;
UPDATE product SET productName = '7311', 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 = '20250',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 = '16474';
UPDATE buybilldetail SET  lastbuyprice = 210 , meanbuyprice = 210, lastbuyprice_withDiscount = 210, meanbuyprice_withDiscount = 210
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where buybilldetailid = 32699;
UPDATE productunit SET proUnitBuyPrice  = 210 * productnumber WHERE productid = 16474;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16473';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16474', '1', '15', '0', '14132', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 15:27: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 ('R3205', '14132', '1', '15411', '15', '550', '8250', '0', '', '2024-12-18 15:29:18', '15411','','','0','0','0','0','0',null,'550','8250','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-18 15:27:20', 1, 15411, 0, 0
                    , 550, 15, 0, 0, 77, '2024-12-18 15:29:18')
                ON DUPLICATE KEY UPDATE buyprice = 550,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:29:18' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15411', '550', '15', '0', 'buyBillController.php', '32700', '', '0', '0');
UPDATE product SET  productBuyPrice = "550" WHERE productId = 15411 ;
UPDATE buybilldetail SET  quantitybefore = 76 WHERE buybilldetailid = 32700 ;
UPDATE product SET productName = 'R3205', productDescription = '', productCatId = '1', productBuyPrice = '550.00', productSellAllPrice = '620.00', productSellUnitPrice = '620.00', productSellHalfPrice = '620.00', productDate = '2024-10-11', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3205',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '550',lastbuyprice_withDiscount = '550',meanbuyprice = '548',meanbuyprice_withDiscount = '548' , 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='497.74',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='471',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 = '15411';
UPDATE buybilldetail SET  lastbuyprice = 550 , meanbuyprice = 548, lastbuyprice_withDiscount = 550, meanbuyprice_withDiscount = 548
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 471, lastbuyprice_withDiscountAndTax = 550
                where buybilldetailid = 32700;
UPDATE productunit SET proUnitBuyPrice  = 550 * productnumber WHERE productid = 15411;
UPDATE storedetail SET  productquantity = '91', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '15410';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15411', '1', '15', '0', '14132', 'اضافة فاتورة مشتريات', 'buyBillController.php', '76', '91', '77', '2024-12-18 15:27: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 ('07313', '14132', '5', '16475', '15', '210', '3150', '0', '', '2024-12-18 15:29:18', '16475','','','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-18 15:27:20', 1, 16475, 0, 0
                    , 210, 15, 0, 0, 77, '2024-12-18 15:29:18')
                ON DUPLICATE KEY UPDATE buyprice = 210,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:29:18' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16475', '210', '15', '0', 'buyBillController.php', '32701', '', '0', '0');
UPDATE product SET  productBuyPrice = "210" WHERE productId = 16475 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32701 ;
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',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 = '16475';
UPDATE buybilldetail SET  lastbuyprice = 210 , meanbuyprice = 210, lastbuyprice_withDiscount = 210, meanbuyprice_withDiscount = 210
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where buybilldetailid = 32701;
UPDATE productunit SET proUnitBuyPrice  = 210 * productnumber WHERE productid = 16475;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16474';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16475', '1', '15', '0', '14132', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 15:27: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 ('07255', '14132', '5', '16369', '30', '210', '6300', '0', '', '2024-12-18 15:29:18', '16369','','','0','0','0','0','0',null,'210','6300','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-18 15:27:20', 1, 16369, 0, 0
                    , 210, 30, 0, 0, 77, '2024-12-18 15:29:18')
                ON DUPLICATE KEY UPDATE buyprice = 210,
                        buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:29:18' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16369', '210', '30', '0', 'buyBillController.php', '32702', '', '0', '0');
UPDATE product SET  productBuyPrice = "210" WHERE productId = 16369 ;
UPDATE buybilldetail SET  quantitybefore = 9 WHERE buybilldetailid = 32702 ;
UPDATE product SET productName = '7255', productDescription = '', productCatId = '5', productBuyPrice = '210.00', productSellAllPrice = '260.00', productSellUnitPrice = '260.00', productSellHalfPrice = '260.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07255',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 = '16369';
UPDATE buybilldetail SET  lastbuyprice = 210 , meanbuyprice = 210, lastbuyprice_withDiscount = 210, meanbuyprice_withDiscount = 210
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where buybilldetailid = 32702;
UPDATE productunit SET proUnitBuyPrice  = 210 * productnumber WHERE productid = 16369;
UPDATE storedetail SET  productquantity = '39', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16368';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16369', '1', '30', '0', '14132', 'اضافة فاتورة مشتريات', 'buyBillController.php', '9', '39', '77', '2024-12-18 15:27:20','0','0');
UPDATE supplier SET  suppliercurrentDebt = '261725',suppliercurrentDebtInCurrency= '261725' , userid = '77', supplierdate = '2024-12-18 15:29:18'   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', '238400.00', '23325', '0', 'اضافة فاتورة مشتريات', '14132', '261725', '2024-12-18 15:27:20', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','23325','1','238400','23325','261725','0');
update buybill set dailyentryid='0,' where buybillid=14132;
COMMIT;
UPDATE product SET overAllAveragePrice = 502.35 WHERE productId = 15411;UPDATE product SET overAllAveragePrice = 210 WHERE productId = 16369;UPDATE product SET overAllAveragePrice = 165 WHERE productId = 16417;UPDATE product SET overAllAveragePrice = 210 WHERE productId = 16474;UPDATE product SET overAllAveragePrice = 210 WHERE productId = 16475;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:59:18";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:29:18", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:29:18', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14132');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:59:38";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:29:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:29:38', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247350
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7151,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '20' , clientdate = '2024-12-18 15:29:38', userid = '2' WHERE clientid = '7151';
UPDATE client SET  inUse = 0 where clientid = 7151;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7151','1646.00','1626','1','ايصال تحصيل (( قبض من عميل ))','247350', '20', '2024-12-18 15:28:45', '2', 'clientPayedDeptController.php', '   ', '1626', '0', null, '0', null, null,'', '-1','1','1','1626','1','','3509','0');
UPDATE save SET  savecurrentvalue = '209785.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('208159.50','1626', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247350', '209785.5', '2024-12-18 15:29:38', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1626', '1626', '2024-12-18', '2', '0', '0', '2024-12-18 15:29:39','اضافة ايصال سداد للعميل ياسمين احمد بنها Z28','1','0','0','0','247350','clientPayedDeptController.php?do=show&id=247350');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122155', '-1', '1626', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1626', 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 ('122155', '-1', '1626', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1626', 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 = '7151', clientdebtchangebefore = '1646.000', clientdebtchangeamount = '1626.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247350', clientdebtchangeafter = '20.000', clientdebtchangedate = '2024-12-18 15:28:45', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1626.00',discount='', reciptid='0', dailyentryid = '122155',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1626',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247350';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 11:59:39";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:29:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:29: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-18 12:00:02";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:30:02", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:30:02', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247351
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5074,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '39' , clientdate = '2024-12-18 15:30:02', userid = '2' WHERE clientid = '5074';
UPDATE client SET  inUse = 0 where clientid = 5074;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5074','3959.00','3920','1','ايصال تحصيل (( قبض من عميل ))','247351', '39', '2024-12-18 15:29:39', '2', 'clientPayedDeptController.php', '   ', '3920', '0', null, '0', null, null,'', '-1','1','1','3920','1','','3510','0');
UPDATE save SET  savecurrentvalue = '1979032',  userid = '2' WHERE saveid = '3';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('1975112.00','3920', '0', '3', 'ايصال تحصيل (( قبض من عميل ))', '247351', '1979032', '2024-12-18 15:30:02', '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', '39.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-18 15:30:02');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '3920', '3920', '2024-12-18', '2', '0', '0', '2024-12-18 15:30:02','اضافة ايصال سداد للعميل ميرنا نجيب','1','0','0','0','247351','clientPayedDeptController.php?do=show&id=247351');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122156', '-1', '3920', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '3920', 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 ('122156', '12552', '3920', '','0');
UPDATE accountstree SET name = 'ميرنا نجيب', customName = 'ميرنا نجيب', customNameEn = 'ميرنا نجيب', nameEn = 'ميرنا نجيب', parent = '58', accountNature = '0', theValue = '-3881', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 15:30:02' WHERE id = '12552';
UPDATE clientdebtchange SET clientid = '5074', clientdebtchangebefore = '3959.000', clientdebtchangeamount = '3920.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247351', clientdebtchangeafter = '39.000', clientdebtchangedate = '2024-12-18 15:29:39', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '3920.00',discount='', reciptid='0', dailyentryid = '122156',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='3920',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247351';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:00:03";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:30:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:30: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-18 12:01:53";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:31:53", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:31:53', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:02:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:32:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:32:01', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762cd03ee6f1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3053,@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-18 15:24:19', '06762cd03ee6f1', '3053', '-313.00', '0', '0', '1', '1168.00', '1168', '855', '313', '1', '2024-12-18 15:32:01', '', '104', '0', 'نجوي محمد B717', '1', '1', '3', '3', 'نجوي محمد B717', '4' ,'0','','','','','-1','0','0','0','0','0','1168','0','','0','0','855','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '0', userid = '104' WHERE clientid = '3053';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3053','-313.00','313','0','اضافة فاتورة مبيعات','150051', '0', '2024-12-18 15:32:01', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1168', '0', null, '0', null, null,'', '0','1','1','313','1','2024-12-18 15:24:19','0','0');
UPDATE client SET  inUse = 0 where clientid = 3053;
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', '150051', '14', '16394', '1', '550', '550', '0', '', '1', '2024-12-18 15:32:01', '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 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 = 548120;
 INSERT INTO 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-18', 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-18', 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 = '13', userid = '104', storedetaildate = '2024-12-18 15:32:01' WHERE storedetailid = '16393';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16394', '1', '1', '1', '150051', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '104', '2024-12-18 15:32:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36455;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06065', '150051', '5', '13529', '1', '305', '305', '0', '', '1', '2024-12-18 15:32:01', '13529', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36455-1,','1','1','0','0','305','305','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 290.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 290.00
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 840, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 548121;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13529, '2024-12-18', 305, 280, 280
                    , 290, 280, 290, 271.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 280, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+305, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+271.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , 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+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 305, 280, 280
                    , 290, 280, 290, 271.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+305, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+271.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , 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 = '3', userid = '104', storedetaildate = '2024-12-18 15:32:01' WHERE storedetailid = '13528';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13529', '1', '1', '1', '150051', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-18 15:32:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34026;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3184', '150051', '1', '15346', '1', '310', '310', '0', '', '1', '2024-12-18 15:32:01', '15346', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34026-1,','1','1','0','0','310','310','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 583.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 583.00
        
                where sellbilldetailid = 548122;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15346, '2024-12-18', 310, 250, 250
                    , 583, 250, 583, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+583
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+583
                            , 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-18', 310, 250, 250
                    , 583, 250, 583, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+583
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+583
                            , 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 = '104', storedetaildate = '2024-12-18 15:32:01' WHERE storedetailid = '15345';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15346', '1', '1', '1', '150051', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-18 15:32: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 ('0','10291', '150051', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-18 15:32:01', '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');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '23155',  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 ('22300','855', '0', '1', 'اضافة فاتورة مبيعات', '150051', '23155', '2024-12-18 15:32:01', '104',  'sellbillController.php','3053','','0');
UPDATE client SET  delegateid = 3 where clientid = 3053;
 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-18', 1168, 990, 990
                    , 1333, 990, 1333, 981.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,740, 1300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1168, sellCostBuyPrice =sellCostBuyPrice+990
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+990, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1333
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+990, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1333
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+981.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+740
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1300
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (3053, '2024-12-18', 1168, 990, 990
                    , 1333, 990, 1333, 981.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,740, 1300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1168, sellCostBuyPrice =sellCostBuyPrice+990
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+990, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1333
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+990, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1333
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+981.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+740
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1300
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1168, 990, 990
                    , 1333, 990, 1333, 981.67, 740, 1300)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1168, netSellCostBuyPrice = netSellCostBuyPrice+990
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+990
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1333
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+990
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1333
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+981.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+740
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1300;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762cd03ee6f1 and sellbillId = 150051 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:02:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:32:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:32:02', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:02:08";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 15:32:08", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:32:08', '101', 'show', '192.168.1.60', '', '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 ('H1677','','14','230','310', '310','310', '2024-12-18', '0', '77', '1', 'H1677', '0', '0', '0', '0', '0', '230','230','230','230','230','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','230','230','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16476, 1,'2024-12-18 15:32:30',77)
                ON DUPLICATE KEY UPDATE productid = 16476, edited = 1, sysdate = '2024-12-18 15:32:30', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16476', '1', '2024-12-18', '77', '0','1647601','310','310','310','230','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16476', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16476', '1', '0', '0', '16476', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:02:34";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 15:32:34", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:32:34', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150050');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:02:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:32:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:32:48', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762cdf674d0a
-- ----------------------------------------------------------------------------------------------------

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-18 15:28:22', '06762cdf674d0a', '1', '0.00', '0', '0', '1', '665.00', '665', '665', '0', '1', '2024-12-18 15:32:48', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','665','0','','0','0','665','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150052', '0', '2024-12-18 15:32:48', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '665', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 15:28:22','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', '150052', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-18 15:32:48', '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 = 285, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 548124;
 INSERT INTO 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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 285, 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+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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 285, 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+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 = '23', userid = '104', storedetaildate = '2024-12-18 15:32:48' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150052', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '104', '2024-12-18 15:32:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32781;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06423', '150052', '5', '14631', '1', '265', '265', '0', '', '1', '2024-12-18 15:32:48', '14631', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32781-1,','1','1','0','0','265','265','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
        
                where sellbilldetailid = 548125;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14631, '2024-12-18', 265, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+265, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 265, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+265, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:32:48' WHERE storedetailid = '14630';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14631', '1', '1', '1', '150052', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-18 15:32:48','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '23820',  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 ('23155','665', '0', '1', 'اضافة فاتورة مبيعات', '150052', '23820', '2024-12-18 15:32:48', '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-18', 665, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+665, sellCostBuyPrice =sellCostBuyPrice+670
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+670, sellCostMeanBuyPrice = sellCostMeanBuyPrice+670
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+670, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+670
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+670
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , 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-18', 665, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+665, sellCostBuyPrice =sellCostBuyPrice+670
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+670, sellCostMeanBuyPrice = sellCostMeanBuyPrice+670
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+670, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+670
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+670
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , 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, 665, 670, 670
                    , 670, 670, 670, 670, 335, 285)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+665, netSellCostBuyPrice = netSellCostBuyPrice+670
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+670
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+670
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+670
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+670
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+670
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+335
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+285;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762cdf674d0a and sellbillId = 150052 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:02:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:32:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:32:49', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:03:36";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:33:36", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:33:36', '77', 'add', '192.168.1.21', '', '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 ('06762cec9d7362', '2024-12-18 15:31:53', '20', '305610.00', '329635', '0', '0', '24025',  '24025', '0', '24025', '1', '2024-12-18 15:33:36', '', '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', '14133', '5', '16279', '15', '335', '5025', '0', '', '2024-12-18 15:33:36', '16279','','','0','0','0','0','0',null,'335','5025','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-18 15:31:53', 1, 16279, 0, 0
                    , 335, 15, 0, 0, 77, '2024-12-18 15:33:36')
                ON DUPLICATE KEY UPDATE buyprice = 335,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:33:36' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16279', '335', '15', '0', 'buyBillController.php', '32703', '', '0', '0');
UPDATE product SET  productBuyPrice = "335" WHERE productId = 16279 ;
UPDATE buybilldetail SET  quantitybefore = 23 WHERE buybilldetailid = 32703 ;
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='305',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 = 305, lastbuyprice_withDiscountAndTax = 335
                where buybilldetailid = 32703;
UPDATE productunit SET proUnitBuyPrice  = 335 * productnumber WHERE productid = 16279;
UPDATE storedetail SET  productquantity = '38', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '15', '0', '14133', 'اضافة فاتورة مشتريات', 'buyBillController.php', '23', '38', '77', '2024-12-18 15:31:53','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 ('H1677', '14133', '14', '16476', '20', '230', '4600', '0', '', '2024-12-18 15:33:36', '16476','','','0','0','0','0','0',null,'230','4600','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-18 15:31:53', 1, 16476, 0, 0
                    , 230, 20, 0, 0, 77, '2024-12-18 15:33:36')
                ON DUPLICATE KEY UPDATE buyprice = 230,
                        buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:33:36' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16476', '230', '20', '0', 'buyBillController.php', '32704', '', '0', '0');
UPDATE product SET  productBuyPrice = "230" WHERE productId = 16476 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32704 ;
UPDATE product SET productName = 'H1677', productDescription = '', productCatId = '14', productBuyPrice = '230.00', productSellAllPrice = '310.00', productSellUnitPrice = '310.00', productSellHalfPrice = '310.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1677',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '230',lastbuyprice_withDiscount = '230',meanbuyprice = '230',meanbuyprice_withDiscount = '230' , productbuypricereal = '230.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='230',meanbuyprice_withTax='230',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 = '16476';
UPDATE buybilldetail SET  lastbuyprice = 230 , meanbuyprice = 230, lastbuyprice_withDiscount = 230, meanbuyprice_withDiscount = 230
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where buybilldetailid = 32704;
UPDATE productunit SET proUnitBuyPrice  = 230 * productnumber WHERE productid = 16476;
UPDATE storedetail SET  productquantity = '20', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16475';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16476', '1', '20', '0', '14133', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '20', '77', '2024-12-18 15:31:53','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 ('H1630', '14133', '14', '16292', '15', '230', '3450', '0', '', '2024-12-18 15:33:36', '16292','','','0','0','0','0','0',null,'230','3450','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-18 15:31:53', 1, 16292, 0, 0
                    , 230, 15, 0, 0, 77, '2024-12-18 15:33:36')
                ON DUPLICATE KEY UPDATE buyprice = 230,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:33:36' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16292', '230', '15', '0', 'buyBillController.php', '32705', '', '0', '0');
UPDATE product SET  productBuyPrice = "230" WHERE productId = 16292 ;
UPDATE buybilldetail SET  quantitybefore = 16 WHERE buybilldetailid = 32705 ;
UPDATE product SET productName = 'H1630', productDescription = '', productCatId = '14', productBuyPrice = '230.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1630',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '230',lastbuyprice_withDiscount = '230',meanbuyprice = '230',meanbuyprice_withDiscount = '230' , productbuypricereal = '230.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='230',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='230',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 = '16292';
UPDATE buybilldetail SET  lastbuyprice = 230 , meanbuyprice = 230, lastbuyprice_withDiscount = 230, meanbuyprice_withDiscount = 230
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where buybilldetailid = 32705;
UPDATE productunit SET proUnitBuyPrice  = 230 * productnumber WHERE productid = 16292;
UPDATE storedetail SET  productquantity = '31', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16291';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16292', '1', '15', '0', '14133', 'اضافة فاتورة مشتريات', 'buyBillController.php', '16', '31', '77', '2024-12-18 15:31:53','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 ('H1651', '14133', '14', '16406', '15', '365', '5475', '0', '', '2024-12-18 15:33:36', '16406','','','0','0','0','0','0',null,'365','5475','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-18 15:31:53', 1, 16406, 0, 0
                    , 365, 15, 0, 0, 77, '2024-12-18 15:33:36')
                ON DUPLICATE KEY UPDATE buyprice = 365,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:33:36' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16406', '365', '15', '0', 'buyBillController.php', '32706', '', '0', '0');
UPDATE product SET  productBuyPrice = "365" WHERE productId = 16406 ;
UPDATE buybilldetail SET  quantitybefore = 10 WHERE buybilldetailid = 32706 ;
UPDATE product SET productName = 'H1651', productDescription = '', productCatId = '14', productBuyPrice = '365.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2024-12-11', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1651',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '365',lastbuyprice_withDiscount = '365',meanbuyprice = '365',meanbuyprice_withDiscount = '365' , 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='365',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='365',meanbuyprice_withTax='365',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='365'  WHERE productId = '16406';
UPDATE buybilldetail SET  lastbuyprice = 365 , meanbuyprice = 365, lastbuyprice_withDiscount = 365, meanbuyprice_withDiscount = 365
        , lastbuyprice_withTax = 365, meanbuyprice_withTax = 365, lastbuyprice_withDiscountAndTax = 365
                where buybilldetailid = 32706;
UPDATE productunit SET proUnitBuyPrice  = 365 * productnumber WHERE productid = 16406;
UPDATE storedetail SET  productquantity = '25', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16405';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16406', '1', '15', '0', '14133', 'اضافة فاتورة مشتريات', 'buyBillController.php', '10', '25', '77', '2024-12-18 15:31:53','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 ('H1656', '14133', '14', '16413', '15', '365', '5475', '0', '', '2024-12-18 15:33:36', '16413','','','0','0','0','0','0',null,'365','5475','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-18 15:31:53', 1, 16413, 0, 0
                    , 365, 15, 0, 0, 77, '2024-12-18 15:33:36')
                ON DUPLICATE KEY UPDATE buyprice = 365,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:33:36' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16413', '365', '15', '0', 'buyBillController.php', '32707', '', '0', '0');
UPDATE product SET  productBuyPrice = "365" WHERE productId = 16413 ;
UPDATE buybilldetail SET  quantitybefore = 10 WHERE buybilldetailid = 32707 ;
UPDATE product SET productName = 'H1656', productDescription = '', productCatId = '14', productBuyPrice = '365.00', productSellAllPrice = '440.00', productSellUnitPrice = '440.00', productSellHalfPrice = '440.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1656',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '365',lastbuyprice_withDiscount = '365',meanbuyprice = '365',meanbuyprice_withDiscount = '365' , productbuypricereal = '365.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='365',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='365',meanbuyprice_withTax='365',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='365'  WHERE productId = '16413';
UPDATE buybilldetail SET  lastbuyprice = 365 , meanbuyprice = 365, lastbuyprice_withDiscount = 365, meanbuyprice_withDiscount = 365
        , lastbuyprice_withTax = 365, meanbuyprice_withTax = 365, lastbuyprice_withDiscountAndTax = 365
                where buybilldetailid = 32707;
UPDATE productunit SET proUnitBuyPrice  = 365 * productnumber WHERE productid = 16413;
UPDATE storedetail SET  productquantity = '25', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16412';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16413', '1', '15', '0', '14133', 'اضافة فاتورة مشتريات', 'buyBillController.php', '10', '25', '77', '2024-12-18 15:31:53','0','0');
UPDATE supplier SET  suppliercurrentDebt = '329635',suppliercurrentDebtInCurrency= '329635' , userid = '77', supplierdate = '2024-12-18 15:33:36'   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', '305610.00', '24025', '0', 'اضافة فاتورة مشتريات', '14133', '329635', '2024-12-18 15:31:53', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','24025','1','305610','24025','329635','0');
update buybill set dailyentryid='0,' where buybillid=14133;
COMMIT;
UPDATE product SET overAllAveragePrice = 335 WHERE productId = 16279;UPDATE product SET overAllAveragePrice = 230 WHERE productId = 16292;UPDATE product SET overAllAveragePrice = 365 WHERE productId = 16406;UPDATE product SET overAllAveragePrice = 365 WHERE productId = 16413;UPDATE product SET overAllAveragePrice = 230 WHERE productId = 16476;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:03:37";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:33:37", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:33:37', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14133');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:05:27";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:35:27", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:35:27', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:05:51";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:35:51", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:35:51', '77', 'add', '192.168.1.21', '', '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 ('06762cf9f7df02', '2024-12-18 15:35:27', '52', '107895.00', '113795', '0', '0', '5900',  '5900', '0', '5900', '1', '2024-12-18 15:35: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 ('06872', '14134', '5', '15654', '20', '295', '5900', '0', '', '2024-12-18 15:35:51', '15654','','','0','0','0','0','0',null,'295','5900','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-18 15:35:27', 1, 15654, 0, 0
                    , 295, 20, 0, 0, 77, '2024-12-18 15:35:51')
                ON DUPLICATE KEY UPDATE buyprice = 295,
                        buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:35:51' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15654', '295', '20', '0', 'buyBillController.php', '32708', '', '0', '0');
UPDATE product SET  productBuyPrice = "295" WHERE productId = 15654 ;
UPDATE buybilldetail SET  quantitybefore = -5 WHERE buybilldetailid = 32708 ;
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 = '356',meanbuyprice_withDiscount = '356' , 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='356',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 = 356, lastbuyprice_withDiscount = 295, meanbuyprice_withDiscount = 356
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 356, lastbuyprice_withDiscountAndTax = 295
                where buybilldetailid = 32708;
UPDATE productunit SET proUnitBuyPrice  = 295 * productnumber WHERE productid = 15654;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '15653';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15654', '1', '20', '0', '14134', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-5', '15', '77', '2024-12-18 15:35:27','0','0');
UPDATE supplier SET  suppliercurrentDebt = '113795',suppliercurrentDebtInCurrency= '113795' , userid = '77', supplierdate = '2024-12-18 15:35:51'   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', '107895.00', '5900', '0', 'اضافة فاتورة مشتريات', '14134', '113795', '2024-12-18 15:35:27', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','5900','1','107895','5900','113795','0');
update buybill set dailyentryid='0,' where buybillid=14134;
COMMIT;
UPDATE product SET overAllAveragePrice = 295 WHERE productId = 15654;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:05:52";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:35:52", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:35:52', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14134');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:07:59";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:37:59", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:37:59', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247352
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7640,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 15:37:59', userid = '2' WHERE clientid = '7640';
UPDATE client SET  inUse = 0 where clientid = 7640;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7640','4370.00','4370','1','ايصال تحصيل (( قبض من عميل ))','247352', '0', '2024-12-18 15:30:03', '2', 'clientPayedDeptController.php', '   ', '4370', '0', null, '0', null, null,'', '-1','1','1','4370','1','','3511','0');
UPDATE save SET  savecurrentvalue = '214155.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('209785.50','4370', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247354', '214155.5', '2024-12-18 15:37: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 ('اسراء عبدالغني b119', 'اسراء عبدالغني b119', 'اسراء عبدالغني b119', 'اسراء عبدالغني b119', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-18 15:37:59');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '4370', '4370', '2024-12-18', '2', '0', '0', '2024-12-18 15:37:59','اضافة ايصال سداد للعميل اسراء عبدالغني b119','1','0','0','0','247354','clientPayedDeptController.php?do=show&id=247354');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122157', '-1', '4370', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '4370', 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 ('122157', '12553', '4370', '','0');
UPDATE accountstree SET name = 'اسراء عبدالغني b119', customName = 'اسراء عبدالغني b119', customNameEn = 'اسراء عبدالغني b119', nameEn = 'اسراء عبدالغني b119', parent = '58', accountNature = '0', theValue = '-4370', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 15:37:59' WHERE id = '12553';
UPDATE clientdebtchange SET clientid = '7640', clientdebtchangebefore = '4370.000', clientdebtchangeamount = '4370.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247352', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 15:30:03', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '4370.00',discount='', reciptid='0', dailyentryid = '122157',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='4370',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247354';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247352 -clientdebtchangeId = 247354
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:08:00";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:38:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:38: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-18 12:08:01";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:38:01", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:38:01', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:08:17";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:38:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:38:17', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247355
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1911,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '479' , clientdate = '2024-12-18 15:38:17', userid = '2' WHERE clientid = '1911';
UPDATE client SET  inUse = 0 where clientid = 1911;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1911','706.00','227','1','ايصال تحصيل (( قبض من عميل ))','247355', '479', '2024-12-18 15:38:00', '2', 'clientPayedDeptController.php', '   ', '227', '0', null, '0', null, null,'', '-1','1','1','227','1','','3512','0');
UPDATE save SET  savecurrentvalue = '214382.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('214155.50','227', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247355', '214382.5', '2024-12-18 15:38:17', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '227', '227', '2024-12-18', '2', '0', '0', '2024-12-18 15:38:17','اضافة ايصال سداد للعميل جيجي المقدم73','1','0','0','0','247355','clientPayedDeptController.php?do=show&id=247355');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122158', '-1', '227', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '227', 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 ('122158', '-1', '227', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-227', 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 = '1911', clientdebtchangebefore = '706.000', clientdebtchangeamount = '227.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247355', clientdebtchangeafter = '479.000', clientdebtchangedate = '2024-12-18 15:38:00', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '227.00',discount='', reciptid='0', dailyentryid = '122158',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='227',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247355';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:08:18";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:38:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:38:18', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:08:21";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:38:21", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 15:38:21', '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-18 12:08:29";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:38:29", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:38:29', '101', 'showDetail', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149860');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:08:44";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:38:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:38:44', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247356
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3988,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '35' , clientdate = '2024-12-18 15:38:44', userid = '2' WHERE clientid = '3988';
UPDATE client SET  inUse = 0 where clientid = 3988;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3988','540.00','505','1','ايصال تحصيل (( قبض من عميل ))','247356', '35', '2024-12-18 15:38:18', '2', 'clientPayedDeptController.php', '   ', '505', '0', null, '0', null, null,'', '-1','1','1','505','1','','3513','0');
UPDATE save SET  savecurrentvalue = '214887.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('214382.50','505', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247356', '214887.5', '2024-12-18 15:38:44', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '505', '505', '2024-12-18', '2', '0', '0', '2024-12-18 15:38:45','اضافة ايصال سداد للعميل هايدي محمد الشرقية f211','1','0','0','0','247356','clientPayedDeptController.php?do=show&id=247356');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122159', '-1', '505', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '505', 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 ('122159', '-1', '505', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-505', 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 = '3988', clientdebtchangebefore = '540.000', clientdebtchangeamount = '505.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247356', clientdebtchangeafter = '35.000', clientdebtchangedate = '2024-12-18 15:38:18', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '505.00',discount='', reciptid='0', dailyentryid = '122159',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='505',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247356';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:08:45";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:38:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:38: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-18 12:09:04";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:39:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:39:04', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247357
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3399,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '41' , clientdate = '2024-12-18 15:39:04', userid = '2' WHERE clientid = '3399';
UPDATE client SET  inUse = 0 where clientid = 3399;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3399','2001.00','1960','1','ايصال تحصيل (( قبض من عميل ))','247357', '41', '2024-12-18 15:38:46', '2', 'clientPayedDeptController.php', '   ', '1960', '0', null, '0', null, null,'', '-1','1','1','1960','1','','3514','0');
UPDATE save SET  savecurrentvalue = '216847.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('214887.50','1960', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247357', '216847.5', '2024-12-18 15:39:04', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1960', '1960', '2024-12-18', '2', '0', '0', '2024-12-18 15:39:05','اضافة ايصال سداد للعميل توفيق مصطفي e64','1','0','0','0','247357','clientPayedDeptController.php?do=show&id=247357');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122160', '-1', '1960', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1960', 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 ('122160', '-1', '1960', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1960', 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 = '3399', clientdebtchangebefore = '2001.000', clientdebtchangeamount = '1960.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247357', clientdebtchangeafter = '41.000', clientdebtchangedate = '2024-12-18 15:38:46', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1960.00',discount='', reciptid='0', dailyentryid = '122160',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1960',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247357';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:09:06";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:39:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:39: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-18 12:09:21";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:39:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:39:21', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247358
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5242,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 15:39:21', userid = '2' WHERE clientid = '5242';
UPDATE client SET  inUse = 0 where clientid = 5242;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5242','616.00','616','1','ايصال تحصيل (( قبض من عميل ))','247358', '0', '2024-12-18 15:39:06', '2', 'clientPayedDeptController.php', '   ', '616', '0', null, '0', null, null,'', '-1','1','1','616','1','','3515','0');
UPDATE save SET  savecurrentvalue = '217463.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('216847.50','616', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247358', '217463.5', '2024-12-18 15:39:21', '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-18 15:39:21');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '616', '616', '2024-12-18', '2', '0', '0', '2024-12-18 15:39:21','اضافة ايصال سداد للعميل يارا طارق ','1','0','0','0','247358','clientPayedDeptController.php?do=show&id=247358');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122161', '-1', '616', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '616', 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 ('122161', '12554', '616', '','0');
UPDATE accountstree SET name = 'يارا طارق ', customName = 'يارا طارق ', customNameEn = 'يارا طارق ', nameEn = 'يارا طارق ', parent = '58', accountNature = '0', theValue = '-616', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 15:39:21' WHERE id = '12554';
UPDATE clientdebtchange SET clientid = '5242', clientdebtchangebefore = '616.000', clientdebtchangeamount = '616.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247358', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 15:39:06', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '616.00',discount='', reciptid='0', dailyentryid = '122161',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='616',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247358';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:09:22";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 15:39:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 15:39:22', '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 ('H1675','','14','450','600', '600','600', '2024-12-18', '0', '77', '1', 'H1675', '0', '0', '0', '0', '0', '450','450','450','450','450','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','450','450','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16477, 1,'2024-12-18 15:39:32',77)
                ON DUPLICATE KEY UPDATE productid = 16477, edited = 1, sysdate = '2024-12-18 15:39:32', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16477', '1', '2024-12-18', '77', '0','1647701','600','600','600','450','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16477', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16477', '1', '0', '0', '16477', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:09:54";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:39:54", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:39:54', '77', 'add', '192.168.1.21', '', '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 ('06762d039bfe53', '2024-12-18 15:38:01', '137', '9980.00', '16730', '0', '0', '6750',  '6750', '0', '6750', '1', '2024-12-18 15:39: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 ('H1675', '14135', '14', '16477', '15', '450', '6750', '0', '', '2024-12-18 15:39:54', '16477','','','0','0','0','0','0',null,'450','6750','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-18 15:38:01', 1, 16477, 0, 0
                    , 450, 15, 0, 0, 77, '2024-12-18 15:39:54')
                ON DUPLICATE KEY UPDATE buyprice = 450,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:39:54' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16477', '450', '15', '0', 'buyBillController.php', '32709', '', '0', '0');
UPDATE product SET  productBuyPrice = "450" WHERE productId = 16477 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32709 ;
UPDATE product SET productName = 'H1675', productDescription = '', productCatId = '14', productBuyPrice = '450.00', productSellAllPrice = '600.00', productSellUnitPrice = '600.00', productSellHalfPrice = '600.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1675',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450.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='450',meanbuyprice_withTax='450',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='450'  WHERE productId = '16477';
UPDATE buybilldetail SET  lastbuyprice = 450 , meanbuyprice = 450, lastbuyprice_withDiscount = 450, meanbuyprice_withDiscount = 450
        , lastbuyprice_withTax = 450, meanbuyprice_withTax = 450, lastbuyprice_withDiscountAndTax = 450
                where buybilldetailid = 32709;
UPDATE productunit SET proUnitBuyPrice  = 450 * productnumber WHERE productid = 16477;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16476';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16477', '1', '15', '0', '14135', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 15:38:01','0','0');
UPDATE supplier SET  suppliercurrentDebt = '16730',suppliercurrentDebtInCurrency= '16730' , userid = '77', supplierdate = '2024-12-18 15:39:54'   WHERE supplierid = '137';
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 ('137', '9980.00', '6750', '0', 'اضافة فاتورة مشتريات', '14135', '16730', '2024-12-18 15:38:01', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','6750','1','9980','6750','16730','0');
update buybill set dailyentryid='0,' where buybillid=14135;
COMMIT;
UPDATE product SET overAllAveragePrice = 450 WHERE productId = 16477;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:09:54";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:39:54", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:39:54', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14135');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:11:52";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:41:52", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:41:52', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:11:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:41:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:41:59', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:13:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:43:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:43:40', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762cf0191143
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6624,@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-18 15:32:49', '06762cf0191143', '6624', '0.00', '960', '0', '1', '960.00', '960', '0', '960', '1', '2024-12-18 15:43:40', '', '104', '0', 'دينا عبدالرؤوف Z17', '1', '1', '3', '97', 'دينا عبدالرؤوف Z17', '4' ,'0','','','','','-1','0','0','0','0','0','960','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '960', userid = '104' WHERE clientid = '6624';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6624','0.00','960','0','اضافة فاتورة مبيعات','150053', '960', '2024-12-18 15:43:40', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '960', '0', null, '0', null, null,'', '0','1','1','960','1','2024-12-18 15:32:49','0','0');
UPDATE client SET  inUse = 0 where clientid = 6624;
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', '150053', '14', '16404', '1', '420', '420', '0', '', '1', '2024-12-18 15:43:40', '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 = 548126;
 INSERT INTO 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-18', 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-18', 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 = '20', userid = '104', storedetaildate = '2024-12-18 15:43:40' WHERE storedetailid = '16403';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16404', '1', '1', '1', '150053', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '104', '2024-12-18 15:43:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36005;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150053', '5', '15855', '1', '210', '210', '0', '', '1', '2024-12-18 15:43:40', '15855', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36005-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 = 548127;
 INSERT INTO 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-18', 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-18', 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 = '26', userid = '104', storedetaildate = '2024-12-18 15:43: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', '150053', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27', '26', '104', '2024-12-18 15:43:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36423;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07169', '150053', '5', '16344', '1', '320', '320', '0', '', '1', '2024-12-18 15:43:40', '16344', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36423-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 249.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 249.00
        , lastbuyprice_withTax = 260, meanbuyprice_withTax = 238, lastbuyprice_withDiscountAndTax = 260
                where sellbilldetailid = 548128;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16344, '2024-12-18', 320, 260, 260
                    , 249, 260, 249, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 260, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , 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-18', 320, 260, 260
                    , 249, 260, 249, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 260, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , 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 = '8', userid = '104', storedetaildate = '2024-12-18 15:43:40' WHERE storedetailid = '16343';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16344', '1', '1', '1', '150053', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-18 15: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 ('0','10291', '150053', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-18 15:43:40', '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 = 97 where clientid = 6624;
 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-18', 960, 745, 745
                    , 734, 745, 734, 745
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,745, 723, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+960, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+734
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+734
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+745
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+723
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (6624, '2024-12-18', 960, 745, 745
                    , 734, 745, 734, 745
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,745, 723, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+960, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+734
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+734
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+745
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+723
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 960, 745, 745
                    , 734, 745, 734, 745, 745, 723)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+960, netSellCostBuyPrice = netSellCostBuyPrice+745
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+745
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+734
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+745
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+734
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+745
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+745
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+723;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762cf0191143 and sellbillId = 150053 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:13:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:43:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:43:41', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:15:27";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:45:27", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:45:27', '77', 'add', '192.168.1.21', '', '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 ('06762d120c1a4c', '2024-12-18 15:41:52', '68', '12065.00', '20690', '0', '0', '8625',  '8625', '0', '8625', '1', '2024-12-18 15:45: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 ('07301', '14136', '5', '16451', '15', '310', '4650', '0', '', '2024-12-18 15:45:27', '16451','','','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-18 15:41:52', 1, 16451, 0, 0
                    , 310, 15, 0, 0, 77, '2024-12-18 15:45:27')
                ON DUPLICATE KEY UPDATE buyprice = 310,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:45:27' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16451', '310', '15', '0', 'buyBillController.php', '32710', '', '0', '0');
UPDATE product SET  productBuyPrice = "310" WHERE productId = 16451 ;
UPDATE buybilldetail SET  quantitybefore = 13 WHERE buybilldetailid = 32710 ;
UPDATE product SET productName = '7301', productDescription = '', productCatId = '5', productBuyPrice = '310.00', productSellAllPrice = '380.00', productSellUnitPrice = '380.00', productSellHalfPrice = '380.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = '07301',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='310',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 = '16451';
UPDATE buybilldetail SET  lastbuyprice = 310 , meanbuyprice = 310, lastbuyprice_withDiscount = 310, meanbuyprice_withDiscount = 310
        , lastbuyprice_withTax = 310, meanbuyprice_withTax = 310, lastbuyprice_withDiscountAndTax = 310
                where buybilldetailid = 32710;
UPDATE productunit SET proUnitBuyPrice  = 310 * productnumber WHERE productid = 16451;
UPDATE storedetail SET  productquantity = '28', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16450';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16451', '1', '15', '0', '14136', 'اضافة فاتورة مشتريات', 'buyBillController.php', '13', '28', '77', '2024-12-18 15:41:52','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 ('07303', '14136', '5', '16452', '15', '265', '3975', '0', '', '2024-12-18 15:45:27', '16452','','','0','0','0','0','0',null,'265','3975','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-18 15:41:52', 1, 16452, 0, 0
                    , 265, 15, 0, 0, 77, '2024-12-18 15:45:27')
                ON DUPLICATE KEY UPDATE buyprice = 265,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:45:27' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16452', '265', '15', '0', 'buyBillController.php', '32711', '', '0', '0');
UPDATE product SET  productBuyPrice = "265" WHERE productId = 16452 ;
UPDATE buybilldetail SET  quantitybefore = 12 WHERE buybilldetailid = 32711 ;
UPDATE product SET productName = '7303', productDescription = '', productCatId = '5', productBuyPrice = '265.00', productSellAllPrice = '320.00', productSellUnitPrice = '320.00', productSellHalfPrice = '320.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = '07303',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '265',lastbuyprice_withDiscount = '265',meanbuyprice = '265',meanbuyprice_withDiscount = '265' , productbuypricereal = '265.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='265',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='265',meanbuyprice_withTax='265',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='265'  WHERE productId = '16452';
UPDATE buybilldetail SET  lastbuyprice = 265 , meanbuyprice = 265, lastbuyprice_withDiscount = 265, meanbuyprice_withDiscount = 265
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 265, lastbuyprice_withDiscountAndTax = 265
                where buybilldetailid = 32711;
UPDATE productunit SET proUnitBuyPrice  = 265 * productnumber WHERE productid = 16452;
UPDATE storedetail SET  productquantity = '27', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16451';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16452', '1', '15', '0', '14136', 'اضافة فاتورة مشتريات', 'buyBillController.php', '12', '27', '77', '2024-12-18 15:41:52','0','0');
UPDATE supplier SET  suppliercurrentDebt = '20690',suppliercurrentDebtInCurrency= '20690' , userid = '77', supplierdate = '2024-12-18 15:45:27'   WHERE supplierid = '68';
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 ('68', '12065.00', '8625', '0', 'اضافة فاتورة مشتريات', '14136', '20690', '2024-12-18 15:41:52', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','8625','1','12065','8625','20690','0');
update buybill set dailyentryid='0,' where buybillid=14136;
COMMIT;
UPDATE product SET overAllAveragePrice = 310 WHERE productId = 16451;UPDATE product SET overAllAveragePrice = 265 WHERE productId = 16452;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:15:28";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:45:28", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:45:28', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14136');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:16:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:46:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:46:01', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762d18d41545
-- ----------------------------------------------------------------------------------------------------

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-18 15:43:41', '06762d18d41545', '1', '0.00', '0', '0', '1', '900.00', '900', '900', '0', '1', '2024-12-18 15:46:02', '', '104', '0', 'نقدي', '1', '0', '3', '8', 'نقدي', '2' ,'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-18','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','اضافة فاتورة مبيعات','150054', '0', '2024-12-18 15:46:02', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '900', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 15:43:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150054', '14', '16178', '2', '450', '900', '0', '', '1', '2024-12-18 15:46:02', '16178', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35646-2,','1','1','0','0','450','900','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 = 548130;
 INSERT INTO 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-18', 900, 750, 750
                    , 750, 750, 750, 750
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 750, 750, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+750, sellCostMeanBuyPrice = sellCostMeanBuyPrice+750
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+750, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+750
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+750
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+750
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+750
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 900, 750, 750
                    , 750, 750, 750, 750
                    , 0, 0, 0, 0
                    , 0, 0, 0, 750, 750, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+750, sellCostMeanBuyPrice = sellCostMeanBuyPrice+750
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+750, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+750
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+750
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+750
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+750
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 15:46:02' WHERE storedetailid = '16177';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16178', '1', '2', '1', '150054', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '4', '104', '2024-12-18 15:46:02','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24720',  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 ('23820','900', '0', '1', 'اضافة فاتورة مبيعات', '150054', '24720', '2024-12-18 15:46:02', '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-18', 900, 750, 750
                    , 750, 750, 750, 750
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,750, 750, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+750, sellCostMeanBuyPrice = sellCostMeanBuyPrice+750
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+750, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+750
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+750
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+750
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+750
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 900, 750, 750
                    , 750, 750, 750, 750
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,750, 750, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+750, sellCostMeanBuyPrice = sellCostMeanBuyPrice+750
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+750, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+750
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+750
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+750
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+750
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 750, 750
                    , 750, 750, 750, 750, 750, 750)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+900, netSellCostBuyPrice = netSellCostBuyPrice+750
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+750
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+750
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+750
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+750
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+750
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+750
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+750;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762d18d41545 and sellbillId = 150054 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:16:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:46:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:46:02', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:16:08";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:46:08", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 15:46:08', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:16:20";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:46:20", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 15:46:20', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:16:55";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:46:55", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:46:55', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:17:43";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:47:43", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierController.php', '2024-12-18 15:47:43', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:18:06";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:48:06", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:48:06', '77', 'bill', '192.168.1.21', '', '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 ('R3347','','1','350','450', '450','450', '2024-12-18', '0', '77', '1', 'R3347', '0', '0', '0', '0', '0', '350','350','350','350','350','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','350','350','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16478, 1,'2024-12-18 15:48:58',77)
                ON DUPLICATE KEY UPDATE productid = 16478, edited = 1, sysdate = '2024-12-18 15:48:58', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16478', '1', '2024-12-18', '77', '0','1647801','450','450','450','350','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16478', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16478', '1', '0', '0', '16478', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','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 ('R3345','','1','370','450', '450','450', '2024-12-18', '0', '77', '1', 'R3345', '0', '0', '0', '0', '0', '370','370','370','370','370','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','370','370','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16479, 1,'2024-12-18 15:49:21',77)
                ON DUPLICATE KEY UPDATE productid = 16479, edited = 1, sysdate = '2024-12-18 15:49: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', '16479', '1', '2024-12-18', '77', '0','1647901','450','450','450','370','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16479', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16479', '1', '0', '0', '16479', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:19:36";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:49:36", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:49:36', '77', 'add', '192.168.1.21', '', '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 ('06762d2964b80d', '2024-12-18 15:48:06', '75', '0.00', '15900', '450', '0', '16350',  '15900', '0', '15900', '1', '2024-12-18 15:49:36', '', '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 ('R3347', '14137', '1', '16478', '15', '350', '5250', '0', '', '2024-12-18 15:49:36', '16478','','','0','0','0','0','0',null,'350','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-18 15:48:06', 1, 16478, 0, 0
                    , 340, 15, 0, 0, 77, '2024-12-18 15:49:37')
                ON DUPLICATE KEY UPDATE buyprice = 340,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:49:37' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16478', '350', '15', '0', 'buyBillController.php', '32712', '', '0', '0');
UPDATE product SET  productBuyPrice = "350" WHERE productId = 16478 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32712 ;
UPDATE product SET productName = 'R3347', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3347',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '350',lastbuyprice_withDiscount = '340',meanbuyprice = '350',meanbuyprice_withDiscount = '340' , 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='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='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='340'  WHERE productId = '16478';
UPDATE buybilldetail SET  lastbuyprice = 350 , meanbuyprice = 350, lastbuyprice_withDiscount = 340, meanbuyprice_withDiscount = 340
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 350, lastbuyprice_withDiscountAndTax = 340
                where buybilldetailid = 32712;
UPDATE productunit SET proUnitBuyPrice  = 350 * productnumber WHERE productid = 16478;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16477';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16478', '1', '15', '0', '14137', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 15:48: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 ('R3345', '14137', '1', '16479', '30', '370', '11100', '0', '', '2024-12-18 15:49:36', '16479','','','0','0','0','0','0',null,'370','11100','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-18 15:48:06', 1, 16479, 0, 0
                    , 360, 30, 0, 0, 77, '2024-12-18 15:49:37')
                ON DUPLICATE KEY UPDATE buyprice = 360,
                        buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:49:37' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16479', '370', '30', '0', 'buyBillController.php', '32713', '', '0', '0');
UPDATE product SET  productBuyPrice = "370" WHERE productId = 16479 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32713 ;
UPDATE product SET productName = 'R3345', productDescription = '', productCatId = '1', productBuyPrice = '370.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3345',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '370',lastbuyprice_withDiscount = '360',meanbuyprice = '370',meanbuyprice_withDiscount = '360' , productbuypricereal = '370.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='370',meanbuyprice_withTax='370',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 = '16479';
UPDATE buybilldetail SET  lastbuyprice = 370 , meanbuyprice = 370, lastbuyprice_withDiscount = 360, meanbuyprice_withDiscount = 360
        , lastbuyprice_withTax = 370, meanbuyprice_withTax = 370, lastbuyprice_withDiscountAndTax = 360
                where buybilldetailid = 32713;
UPDATE productunit SET proUnitBuyPrice  = 370 * productnumber WHERE productid = 16479;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16478';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16479', '1', '30', '0', '14137', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '30', '77', '2024-12-18 15:48:06','0','0');
UPDATE supplier SET  suppliercurrentDebt = '15900',suppliercurrentDebtInCurrency= '15900' , userid = '77', supplierdate = '2024-12-18 15:49:36'   WHERE supplierid = '75';
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 ('75', '0.00', '15900', '0', 'اضافة فاتورة مشتريات', '14137', '15900', '2024-12-18 15:48:06', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','15900','1','0','15900','15900','0');
update buybill set dailyentryid='0,' where buybillid=14137;
COMMIT;
UPDATE product SET overAllAveragePrice = 340.37 WHERE productId = 16478;UPDATE product SET overAllAveragePrice = 359.82 WHERE productId = 16479;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:19:37";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:49:37", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:49:37', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14137');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:21:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:51:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:51:14', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762d21b148a9
-- ----------------------------------------------------------------------------------------------------

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-18 15:46:03', '06762d21b148a9', '1', '0.00', '0', '0', '1', '310.00', '310', '310', '0', '1', '2024-12-18 15:51:14', '', '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-18','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','اضافة فاتورة مبيعات','150055', '0', '2024-12-18 15:51:14', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '310', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 15:46:03','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35547;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07116', '150055', '5', '16138', '1', '310', '310', '0', '', '1', '2024-12-18 15:51:14', '16138', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35547-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 = 548131;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16138, '2024-12-18', 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-18', 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 = '4', userid = '104', storedetaildate = '2024-12-18 15:51:14' WHERE storedetailid = '16137';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16138', '1', '1', '1', '150055', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-18 15:51:14','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '25030',  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 ('24720','310', '0', '1', 'اضافة فاتورة مبيعات', '150055', '25030', '2024-12-18 15:51:14', '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-18', 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;
 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-18', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 310, 260, 260
                    , 260, 260, 260, 260, 260, 260)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+310, netSellCostBuyPrice = netSellCostBuyPrice+260
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+260
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+260
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+260
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+260
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+260
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+260
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+260;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762d21b148a9 and sellbillId = 150055 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:21:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:51:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:51:15', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:21:17";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:51:17", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:51:17', '77', 'bill', '192.168.1.21', '', '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 ('K806','','7','230','300', '300','300', '2024-12-18', '0', '77', '1', '0K806', '0', '0', '0', '0', '0', '230','230','230','230','230','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','230','230','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16480, 1,'2024-12-18 15:52:15',77)
                ON DUPLICATE KEY UPDATE productid = 16480, edited = 1, sysdate = '2024-12-18 15:52: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', '16480', '1', '2024-12-18', '77', '0','1648001','300','300','300','230','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16480', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16480', '1', '0', '0', '16480', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE productunit SET unitid = '1', productid = '16480', productnumber = '1.00', productunitdate = '2024-12-18', userid = '77', conditions = '0',proUnitParcode='1648001',proUnitSellAllPrice='300',proUnitSellHalfPrice='300',proUnitSellUnitPrice ='300',proUnitBuyPrice='230',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16480';
UPDATE product SET productName = 'K806', productDescription = '', productCatId = '7', productBuyPrice = '240', productSellAllPrice = '300', productSellUnitPrice = '300', productSellHalfPrice = '300', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '0K806',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '230.00',lastbuyprice_withDiscount = '230',meanbuyprice = '235',meanbuyprice_withDiscount = '235' , productbuypricereal = '230' , 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='230',meanbuyprice_withTax='230',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 = '16480';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:22:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:52:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:52:42', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762d35329599
-- ----------------------------------------------------------------------------------------------------

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-18 15:51:15', '06762d35329599', '1', '0.00', '0', '0', '1', '1060.00', '1060', '1060', '0', '1', '2024-12-18 15:52:43', '', '104', '0', 'نقدي', '1', '0', '3', '96', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150056', '0', '2024-12-18 15:52:43', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1060', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 15:51:15','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', '150056', '14', '16204', '1', '610', '610', '0', '', '1', '2024-12-18 15:52:43', '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 = 548132;
 INSERT INTO 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-18', 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-18', 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 = '104', storedetaildate = '2024-12-18 15:52:43' WHERE storedetailid = '16203';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16204', '1', '1', '1', '150056', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-1', '-2', '104', '2024-12-18 15:52:43','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35980;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150056', '1', '16325', '1', '450', '450', '0', '', '1', '2024-12-18 15:52:43', '16325', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35980-1,','1','1','0','0','450','450','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 = 548133;
 INSERT INTO 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-18', 450, 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+450, 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-18', 450, 380, 380
                    , 380, 380, 380, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 380, 380, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, 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 = '32', userid = '104', storedetaildate = '2024-12-18 15:52:43' WHERE storedetailid = '16324';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16325', '1', '1', '1', '150056', 'اضافة فاتورة مبيعات', 'sellbillController.php', '33', '32', '104', '2024-12-18 15:52:43','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '26090',  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 ('25030','1060', '0', '1', 'اضافة فاتورة مبيعات', '150056', '26090', '2024-12-18 15:52:43', '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-18', 1060, 880, 880
                    , 1485, 880, 1485, 880
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,880, 2090, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1060, sellCostBuyPrice =sellCostBuyPrice+880
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+880, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1485
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+880, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1485
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+880
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+880
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2090
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1060, 880, 880
                    , 1485, 880, 1485, 880
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,880, 2090, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1060, sellCostBuyPrice =sellCostBuyPrice+880
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+880, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1485
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+880, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1485
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+880
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+880
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2090
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 880, 880
                    , 1485, 880, 1485, 880, 880, 2090)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1060, netSellCostBuyPrice = netSellCostBuyPrice+880
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+880
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1485
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+880
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1485
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+880
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+880
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2090;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762d35329599 and sellbillId = 150056 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762d3abd936e
-- ----------------------------------------------------------------------------------------------------

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-18 15:52:43', '06762d3abd936e', '1', '0.00', '0', '0', '1', '320.00', '320', '320', '0', '1', '2024-12-18 15:54:32', '', '104', '0', 'نقدي', '1', '0', '3', '8', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150057', '0', '2024-12-18 15:54:32', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '320', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 15:52: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 ('380','06107', '150057', '5', '13802', '1', '320', '320', '0', '', '1', '2024-12-18 15:54:32', '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 = 548134;
 INSERT INTO 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-18', 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-18', 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 = '0', userid = '104', storedetaildate = '2024-12-18 15:54:32' WHERE storedetailid = '13801';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13802', '1', '1', '1', '150057', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-18 15:54:32','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '26410',  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 ('26090','320', '0', '1', 'اضافة فاتورة مبيعات', '150057', '26410', '2024-12-18 15:54:32', '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-18', 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;
 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-18', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 320, 380, 380
                    , 532, 380, 532, 380, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+320, netSellCostBuyPrice = netSellCostBuyPrice+380
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+380
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+532
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+380
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+532
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+380
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762d3abd936e and sellbillId = 150057 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:24:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:54:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:54:33', '104', 'addsellBill', '192.168.1.13', '', '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 ('7319','','5','200','250', '250','250', '2024-12-18', '0', '77', '1', '07319', '0', '0', '0', '0', '0', '200','200','200','200','200','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','200','200','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16481, 1,'2024-12-18 15:54:49',77)
                ON DUPLICATE KEY UPDATE productid = 16481, edited = 1, sysdate = '2024-12-18 15:54: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', '16481', '1', '2024-12-18', '77', '0','1648101','250','250','250','200','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16481', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16481', '1', '0', '0', '16481', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:25:23";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:55:23", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:55:23', '77', 'add', '192.168.1.21', '', '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 ('06762d355e064e', '2024-12-18 15:51:17', '34', '131925.00', '152475', '0', '0', '20550',  '20550', '0', '20550', '1', '2024-12-18 15:55: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 ('0K806', '14138', '7', '16480', '15', '230', '3450', '0', '', '2024-12-18 15:55:23', '16480','','','0','0','0','0','0',null,'230','3450','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-18 15:51:17', 1, 16480, 0, 0
                    , 230, 15, 0, 0, 77, '2024-12-18 15:55:23')
                ON DUPLICATE KEY UPDATE buyprice = 230,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:55:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16480', '230', '15', '0', 'buyBillController.php', '32714', '', '0', '0');
UPDATE product SET  productBuyPrice = "230" WHERE productId = 16480 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32714 ;
UPDATE product SET productName = 'K806', productDescription = '', productCatId = '7', productBuyPrice = '230.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '0K806',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '230',lastbuyprice_withDiscount = '230',meanbuyprice = '230',meanbuyprice_withDiscount = '230' , productbuypricereal = '230.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='230',meanbuyprice_withTax='230',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 = '16480';
UPDATE buybilldetail SET  lastbuyprice = 230 , meanbuyprice = 230, lastbuyprice_withDiscount = 230, meanbuyprice_withDiscount = 230
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where buybilldetailid = 32714;
UPDATE productunit SET proUnitBuyPrice  = 230 * productnumber WHERE productid = 16480;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16479';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16480', '1', '15', '0', '14138', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 15:51:17','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 ('0K806', '14138', '7', '16480', '15', '240', '3600', '0', '', '2024-12-18 15:55:23', '16480','','','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-18 15:51:17', 1, 16480, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-18 15:55:23')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:55:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16480', '240', '15', '0', 'buyBillController.php', '32715', '', '0', '0');
UPDATE product SET  productBuyPrice = "240" WHERE productId = 16480 ;
UPDATE buybilldetail SET  quantitybefore = 15 WHERE buybilldetailid = 32715 ;
UPDATE product SET productName = 'K806', productDescription = '', productCatId = '7', productBuyPrice = '240.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '0K806',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '240',lastbuyprice_withDiscount = '240',meanbuyprice = '240',meanbuyprice_withDiscount = '240' , productbuypricereal = '230.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 = '16480';
UPDATE buybilldetail SET  lastbuyprice = 240 , meanbuyprice = 240, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 240
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32715;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16480;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16479';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16480', '1', '15', '0', '14138', 'اضافة فاتورة مشتريات', 'buyBillController.php', '15', '30', '77', '2024-12-18 15:51:17','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 ('07319', '14138', '5', '16481', '30', '200', '6000', '0', '', '2024-12-18 15:55:23', '16481','','','0','0','0','0','0',null,'200','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-18 15:51:17', 1, 16481, 0, 0
                    , 200, 30, 0, 0, 77, '2024-12-18 15:55:23')
                ON DUPLICATE KEY UPDATE buyprice = 200,
                        buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:55:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16481', '200', '30', '0', 'buyBillController.php', '32716', '', '0', '0');
UPDATE product SET  productBuyPrice = "200" WHERE productId = 16481 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32716 ;
UPDATE product SET productName = '7319', productDescription = '', productCatId = '5', productBuyPrice = '200.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '250.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07319',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200',lastbuyprice_withDiscount = '200',meanbuyprice = '200',meanbuyprice_withDiscount = '200' , 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='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='200',meanbuyprice_withTax='200',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='200'  WHERE productId = '16481';
UPDATE buybilldetail SET  lastbuyprice = 200 , meanbuyprice = 200, lastbuyprice_withDiscount = 200, meanbuyprice_withDiscount = 200
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where buybilldetailid = 32716;
UPDATE productunit SET proUnitBuyPrice  = 200 * productnumber WHERE productid = 16481;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16480';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16481', '1', '30', '0', '14138', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '30', '77', '2024-12-18 15:51:17','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 ('H1461', '14138', '14', '15848', '15', '500', '7500', '0', '', '2024-12-18 15:55:23', '15848','','','0','0','0','0','0',null,'500','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-18 15:51:17', 1, 15848, 0, 0
                    , 500, 15, 0, 0, 77, '2024-12-18 15:55:23')
                ON DUPLICATE KEY UPDATE buyprice = 500,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 15:55:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15848', '500', '15', '0', 'buyBillController.php', '32717', '', '0', '0');
UPDATE product SET  productBuyPrice = "500" WHERE productId = 15848 ;
UPDATE buybilldetail SET  quantitybefore = 12 WHERE buybilldetailid = 32717 ;
UPDATE product SET productName = 'H1461', productDescription = '', productCatId = '14', productBuyPrice = '500.00', productSellAllPrice = '620.00', productSellUnitPrice = '620.00', productSellHalfPrice = '620.00', productDate = '2024-11-05', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1461',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='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='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='500'  WHERE productId = '15848';
UPDATE buybilldetail SET  lastbuyprice = 500 , meanbuyprice = 500, lastbuyprice_withDiscount = 500, meanbuyprice_withDiscount = 500
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 520, lastbuyprice_withDiscountAndTax = 500
                where buybilldetailid = 32717;
UPDATE productunit SET proUnitBuyPrice  = 500 * productnumber WHERE productid = 15848;
UPDATE storedetail SET  productquantity = '27', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '15847';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15848', '1', '15', '0', '14138', 'اضافة فاتورة مشتريات', 'buyBillController.php', '12', '27', '77', '2024-12-18 15:51:17','0','0');
UPDATE supplier SET  suppliercurrentDebt = '152475',suppliercurrentDebtInCurrency= '152475' , userid = '77', supplierdate = '2024-12-18 15:55:23'   WHERE supplierid = '34';
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 ('34', '131925.00', '20550', '0', 'اضافة فاتورة مشتريات', '14138', '152475', '2024-12-18 15:51:17', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','20550','1','131925','20550','152475','0');
update buybill set dailyentryid='0,' where buybillid=14138;
COMMIT;
UPDATE product SET overAllAveragePrice = 500 WHERE productId = 15848;UPDATE product SET overAllAveragePrice = 235 WHERE productId = 16480;UPDATE product SET overAllAveragePrice = 200 WHERE productId = 16481;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:25:24";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 15:55:24", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 15:55:24', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14138');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:27:36";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 15:57:36", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:57:36', '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-18 12:28:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:58:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:58:55', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762d4195c4b2
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6227,@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-18 15:54:33', '06762d4195c4b2', '6227', '0.00', '293', '0', '1', '293.00', '293', '0', '293', '1', '2024-12-18 15:58:55', '', '104', '0', 'ام كنزي القاهرة 43', '1', '1', '3', '24', 'ام كنزي القاهرة 43', '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-18','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 = '6227';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6227','0.00','293','0','اضافة فاتورة مبيعات','150058', '293', '2024-12-18 15:58:55', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '293', '0', null, '0', null, null,'', '0','1','1','293','1','2024-12-18 15:54:33','0','0');
UPDATE client SET  inUse = 0 where clientid = 6227;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35518;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150058', '5', '16114', '1', '290', '290', '0', '', '1', '2024-12-18 15:58:55', '16114', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35518-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 = 548135;
 INSERT INTO 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-18', 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-18', 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 = '17', userid = '104', storedetaildate = '2024-12-18 15:58:55' WHERE storedetailid = '16113';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16114', '1', '1', '1', '150058', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '104', '2024-12-18 15:58: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 ('0','10291', '150058', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-18 15:58:55', '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 = 24 where clientid = 6227;
 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-18', 293, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+293, 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 (6227, '2024-12-18', 293, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+293, 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, 293, 240, 240
                    , 240, 240, 240, 240, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+293, 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 06762d4195c4b2 and sellbillId = 150058 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:28:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 15:58:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:58:56', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:29:00";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 15:59:00", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 15:59:00', '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-18 12:30:21";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:00:21", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:00:21', '77', 'bill', '192.168.1.21', '', '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 ('7321','','5','480','550', '550','550', '2024-12-18', '0', '77', '1', '07321', '0', '0', '0', '0', '0', '480','480','480','480','480','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','480','480','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16482, 1,'2024-12-18 16:01:44',77)
                ON DUPLICATE KEY UPDATE productid = 16482, edited = 1, sysdate = '2024-12-18 16:01:44', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16482', '1', '2024-12-18', '77', '0','1648201','550','550','550','480','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16482', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16482', '1', '0', '0', '16482', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:31:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:01:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:01:54', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762d52069c12
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7978,@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-18 15:58:56', '06762d52069c12', '7978', '0.00', '1020', '0', '1', '1020.00', '1020', '0', '1020', '1', '2024-12-18 16:01:54', '', '104', '0', 'يمني يحيي b14', '1', '1', '3', '93', 'يمني يحيي b14', '3' ,'0','','','','','-1','0','0','0','0','0','1020','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1020', userid = '104' WHERE clientid = '7978';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7978','0.00','1020','0','اضافة فاتورة مبيعات','150059', '1020', '2024-12-18 16:01:54', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1020', '0', null, '0', null, null,'', '0','1','1','1020','1','2024-12-18 15:58:56','0','0');
UPDATE client SET  inUse = 0 where clientid = 7978;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35968;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150059', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-18 16:01:54', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35968-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 = 548137;
 INSERT INTO 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-18', 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-18', 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 = '53', userid = '104', storedetaildate = '2024-12-18 16:01:54' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '150059', 'اضافة فاتورة مبيعات', 'sellbillController.php', '54', '53', '104', '2024-12-18 16:01:54','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', '150059', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-18 16:01:54', '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 = 548138;
 INSERT INTO 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-18', 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-18', 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 = '39', userid = '104', storedetaildate = '2024-12-18 16:01:54' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '150059', 'اضافة فاتورة مبيعات', 'sellbillController.php', '40', '39', '104', '2024-12-18 16:01: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 ('0','10291', '150059', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-18 16:01:54', '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 = 93 where clientid = 7978;
 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-18', 1020, 885, 885
                    , 885, 885, 885, 885
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,885, 885, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1020, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7978, '2024-12-18', 1020, 885, 885
                    , 885, 885, 885, 885
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,885, 885, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1020, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1020, 885, 885
                    , 885, 885, 885, 885, 885, 885)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1020, netSellCostBuyPrice = netSellCostBuyPrice+885
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+885
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+885
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+885
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+885
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+885
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+885
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+885;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762d52069c12 and sellbillId = 150059 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:31:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:01:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:01:55', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:33:21";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:03:21", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:03:21', '77', 'add', '192.168.1.21', '', '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 ('06762d57531a6b', '2024-12-18 16:00:21', '101', '136910.00', '152310', '0', '0', '15400',  '15400', '0', '15400', '1', '2024-12-18 16:03: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 ('07295', '14139', '5', '16428', '10', '420', '4200', '0', '', '2024-12-18 16:03:21', '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-18 16:00:21', 1, 16428, 0, 0
                    , 420, 10, 0, 0, 77, '2024-12-18 16:03:21')
                ON DUPLICATE KEY UPDATE buyprice = 420,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:03:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16428', '420', '10', '0', 'buyBillController.php', '32718', '', '0', '0');
UPDATE product SET  productBuyPrice = "420" WHERE productId = 16428 ;
UPDATE buybilldetail SET  quantitybefore = 22 WHERE buybilldetailid = 32718 ;
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 = 32718;
UPDATE productunit SET proUnitBuyPrice  = 420 * productnumber WHERE productid = 16428;
UPDATE storedetail SET  productquantity = '32', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16427';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16428', '1', '10', '0', '14139', 'اضافة فاتورة مشتريات', 'buyBillController.php', '22', '32', '77', '2024-12-18 16:00:21','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', '14139', '1', '16440', '10', '400', '4000', '0', '', '2024-12-18 16:03:21', '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-18 16:00:21', 1, 16440, 0, 0
                    , 400, 10, 0, 0, 77, '2024-12-18 16:03:21')
                ON DUPLICATE KEY UPDATE buyprice = 400,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:03:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16440', '400', '10', '0', 'buyBillController.php', '32719', '', '0', '0');
UPDATE product SET  productBuyPrice = "400" WHERE productId = 16440 ;
UPDATE buybilldetail SET  quantitybefore = 32 WHERE buybilldetailid = 32719 ;
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 = 32719;
UPDATE productunit SET proUnitBuyPrice  = 400 * productnumber WHERE productid = 16440;
UPDATE storedetail SET  productquantity = '42', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16439';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16440', '1', '10', '0', '14139', 'اضافة فاتورة مشتريات', 'buyBillController.php', '32', '42', '77', '2024-12-18 16:00:21','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 ('07321', '14139', '5', '16482', '15', '480', '7200', '0', '', '2024-12-18 16:03:21', '16482','','','0','0','0','0','0',null,'480','7200','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-18 16:00:21', 1, 16482, 0, 0
                    , 480, 15, 0, 0, 77, '2024-12-18 16:03:21')
                ON DUPLICATE KEY UPDATE buyprice = 480,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:03:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16482', '480', '15', '0', 'buyBillController.php', '32720', '', '0', '0');
UPDATE product SET  productBuyPrice = "480" WHERE productId = 16482 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32720 ;
UPDATE product SET productName = '7321', productDescription = '', productCatId = '5', productBuyPrice = '480.00', productSellAllPrice = '550.00', productSellUnitPrice = '550.00', productSellHalfPrice = '550.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07321',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '480',lastbuyprice_withDiscount = '480',meanbuyprice = '480',meanbuyprice_withDiscount = '480' , productbuypricereal = '480.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='480',meanbuyprice_withTax='480',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='480'  WHERE productId = '16482';
UPDATE buybilldetail SET  lastbuyprice = 480 , meanbuyprice = 480, lastbuyprice_withDiscount = 480, meanbuyprice_withDiscount = 480
        , lastbuyprice_withTax = 480, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 480
                where buybilldetailid = 32720;
UPDATE productunit SET proUnitBuyPrice  = 480 * productnumber WHERE productid = 16482;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16481';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16482', '1', '15', '0', '14139', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 16:00:21','0','0');
UPDATE supplier SET  suppliercurrentDebt = '152310',suppliercurrentDebtInCurrency= '152310' , userid = '77', supplierdate = '2024-12-18 16:03:21'   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', '136910.00', '15400', '0', 'اضافة فاتورة مشتريات', '14139', '152310', '2024-12-18 16:00:21', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','15400','1','136910','15400','152310','0');
update buybill set dailyentryid='0,' where buybillid=14139;
COMMIT;
UPDATE product SET overAllAveragePrice = 420 WHERE productId = 16428;UPDATE product SET overAllAveragePrice = 400 WHERE productId = 16440;UPDATE product SET overAllAveragePrice = 480 WHERE productId = 16482;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:33:22";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:03:22", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:03:22', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14139');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:34:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:04:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:04:24', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762d5d3a9de4
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3444,@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-18 16:01:55', '06762d5d3a9de4', '3444', '0.00', '1020', '0', '1', '1020.00', '1020', '0', '1020', '1', '2024-12-18 16:04:24', '', '104', '0', 'مروة سالم', '1', '1', '3', '97', 'مروة سالم', '3' ,'0','','','','','-1','0','0','0','0','0','1020','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1020', userid = '104' WHERE clientid = '3444';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3444','0.00','1020','0','اضافة فاتورة مبيعات','150060', '1020', '2024-12-18 16:04:24', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1020', '0', null, '0', null, null,'', '0','1','1','1020','1','2024-12-18 16:01:55','0','0');
UPDATE client SET  inUse = 0 where clientid = 3444;
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', '150060', '14', '16470', '1', '610', '610', '0', '', '1', '2024-12-18 16:04:24', '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 = 548140;
 INSERT INTO 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-18', 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-18', 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 = '104', storedetaildate = '2024-12-18 16:04:24' WHERE storedetailid = '16469';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16470', '1', '1', '1', '150060', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '104', '2024-12-18 16:04:24','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', '150060', '14', '16346', '1', '400', '400', '0', '', '1', '2024-12-18 16:04:24', '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 = 548141;
 INSERT INTO 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-18', 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-18', 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 = '20', userid = '104', storedetaildate = '2024-12-18 16:04:24' WHERE storedetailid = '16345';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16346', '1', '1', '1', '150060', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '104', '2024-12-18 16:04:24','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', '150060', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-18 16:04:24', '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 = 97 where clientid = 3444;
 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-18', 1020, 850, 850
                    , 850, 850, 850, 850
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,850, 850, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1020, sellCostBuyPrice =sellCostBuyPrice+850
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+850, sellCostMeanBuyPrice = sellCostMeanBuyPrice+850
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+850, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+850
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+850
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+850
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+850
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (3444, '2024-12-18', 1020, 850, 850
                    , 850, 850, 850, 850
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,850, 850, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1020, sellCostBuyPrice =sellCostBuyPrice+850
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+850, sellCostMeanBuyPrice = sellCostMeanBuyPrice+850
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+850, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+850
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+850
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+850
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+850
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1020, 850, 850
                    , 850, 850, 850, 850, 850, 850)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1020, netSellCostBuyPrice = netSellCostBuyPrice+850
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+850
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+850
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+850
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+850
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+850
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+850
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+850;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762d5d3a9de4 and sellbillId = 150060 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:34:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:04:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:04:25', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:35:04";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:05:04", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:05:04', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=4');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:37:45";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:07:45", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:07:45', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762cbcc88c4c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10296,@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-18 15:19:08', '06762cbcc88c4c', '10296', '3712.00', '4343', '0', '1', '631.00', '631', '0', '631', '1', '2024-12-18 16:07:46', '', '75', '0', 'اسماء طنطا 58', '2', '1', '3', '80', 'اسماء طنطا 58', '4' ,'0','','','','','-1','0','0','0','0','0','631','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '4343', userid = '75' WHERE clientid = '10296';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10296','3712.00','631','0','اضافة فاتورة مبيعات','150061', '4343', '2024-12-18 16:07:46', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '631', '0', null, '0', null, null,'', '0','1','1','631','1','2024-12-18 15:19:08','0','0');
UPDATE client SET  inUse = 0 where clientid = 10296;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31890;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2891', '150061', '1', '14325', '1', '240', '240', '0', '', '1', '2024-12-18 16:07:46', '14325', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31890-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 229.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 229.00
        
                where sellbilldetailid = 548143;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14325, '2024-12-18', 240, 200, 200
                    , 229, 200, 229, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+229
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+229
                            , 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-18', 240, 200, 200
                    , 229, 200, 229, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+229
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+229
                            , 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 = '1', userid = '75', storedetaildate = '2024-12-18 16:07:46' WHERE storedetailid = '14324';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14325', '1', '1', '1', '150061', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-18 16:07:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31580;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2854', '150061', '1', '14195', '1', '215', '215', '0', '', '1', '2024-12-18 16:07:46', '14195', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31580-1,','1','1','0','0','215','215','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
        
                where sellbilldetailid = 548144;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14195, '2024-12-18', 215, 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+215, 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-18', 215, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+215, 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 = '6', userid = '75', storedetaildate = '2024-12-18 16:07:46' WHERE storedetailid = '14194';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14195', '1', '1', '1', '150061', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-18 16:07:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31899;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2889', '150061', '1', '14330', '1', '170', '170', '0', '', '1', '2024-12-18 16:07:46', '14330', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31899-1,','1','1','0','0','170','170','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 = 548145;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14330, '2024-12-18', 170, 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+170, 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-18', 170, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, 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 = '1', userid = '75', storedetaildate = '2024-12-18 16:07:46' WHERE storedetailid = '14329';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14330', '1', '1', '1', '150061', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-18 16:07: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', '150061', '17', '10291', '1', '6', '6', '0', '', '1', '2024-12-18 16:07:46', '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 = 80 where clientid = 10296;
 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-18', 631, 660, 660
                    , 689, 660, 689, 660
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+631, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+689
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+689
                            , 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10296, '2024-12-18', 631, 660, 660
                    , 689, 660, 689, 660
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+631, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+689
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+689
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 631, 660, 660
                    , 689, 660, 689, 660, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+631, netSellCostBuyPrice = netSellCostBuyPrice+660
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+660
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+689
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+660
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+689
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+660
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762cbcc88c4c and sellbillId = 150061 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:37:46";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:07:46", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:07:46', '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-18 12:40:23";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:10:23", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:10:23', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762d732e5379
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6868,@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-18 16:07:46', '06762d732e5379', '6868', '0.00', '737', '0', '1', '737.00', '737', '0', '737', '1', '2024-12-18 16:10:23', '', '75', '0', 'اسراء فؤاد E211', '2', '1', '3', '78', 'اسراء فؤاد E211', '4' ,'0','','','','','-1','0','0','0','0','0','737','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '737', userid = '75' WHERE clientid = '6868';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6868','0.00','737','0','اضافة فاتورة مبيعات','150062', '737', '2024-12-18 16:10:23', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '737', '0', null, '0', null, null,'', '0','1','1','737','1','2024-12-18 16:07:46','0','0');
UPDATE client SET  inUse = 0 where clientid = 6868;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36155;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150062', '14', '15838', '1', '430', '430', '0', '', '1', '2024-12-18 16:10:23', '15838', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36155-1,','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 = 548147;
 INSERT INTO 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-18', 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-18', 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 = '12', userid = '75', storedetaildate = '2024-12-18 16:10:23' WHERE storedetailid = '15837';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15838', '1', '1', '1', '150062', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-18 16:10:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35892;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07066', '150062', '5', '16069', '1', '280', '280', '0', '', '1', '2024-12-18 16:10:23', '16069', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35892-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 = 548148;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16069, '2024-12-18', 280, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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-18', 280, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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 = '30', userid = '75', storedetaildate = '2024-12-18 16:10:23' WHERE storedetailid = '16068';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16069', '1', '1', '1', '150062', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31', '30', '75', '2024-12-18 16:10: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 ('20','50235', '150062', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 16:10:23', '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', '150062', '17', '10291', '1', '7', '7', '0', '', '1', '2024-12-18 16:10:23', '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 = 78 where clientid = 6868;
 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-18', 737, 580, 580
                    , 579, 580, 579, 576.92
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,580, 579, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+737, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+579
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+579
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+576.92
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+579
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (6868, '2024-12-18', 737, 580, 580
                    , 579, 580, 579, 576.92
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,580, 579, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+737, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+579
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+579
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+576.92
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+579
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 737, 580, 580
                    , 579, 580, 579, 576.92, 580, 579)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+737, netSellCostBuyPrice = netSellCostBuyPrice+580
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+580
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+579
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+580
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+579
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+576.92
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+580
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+579;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762d732e5379 and sellbillId = 150062 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:40:24";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:10:24", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:10:24', '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-18 12:41:11";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:11:11", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 16:11:11', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:44:17";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:14:17", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 16:14:17', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:44:31";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:14:31", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:14:31', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:44:53";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:14:53", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:14:53', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:45:05";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:15:05", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:15:05', '77', 'editbill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editbill&id=13940');
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 ('7292','','5','240','300', '300','300', '2024-12-18', '0', '77', '1', '07292', '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 (16483, 1,'2024-12-18 16:15:44',77)
                ON DUPLICATE KEY UPDATE productid = 16483, edited = 1, sysdate = '2024-12-18 16:15:44', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16483', '1', '2024-12-18', '77', '0','1648301','300','300','300','240','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16483', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16483', '1', '0', '0', '16483', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:45:51";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:15:51", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:15:51', '77', 'update', '192.168.1.21', '', '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 = 13940;
UPDATE buybill SET  buybillsysdate = '2024-12-18 16:15:51', userid = '77',delbyuserid = '77', conditions = '1' WHERE buybillid = '13940';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-04 10:49:50', 1, 16245, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-18 16:15:51')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-15, sellQuantity = sellQuantity-0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:15:51' ;
UPDATE product SET productName = '7177', productDescription = '', productCatId = '5', productBuyPrice = '240.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2024-12-03', conditions = '0', userId = '77', limitamount = '1', parcode = '07177',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='0'  WHERE productId = '16245';
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16245;
UPDATE storedetail SET  productquantity = '5', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16244';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16245', '1', '15', '1', '13940', 'حذف فاتورة مشتريات - للتعديل', 'buyBillController.php', '20', '5', '77', '2024-12-04 10:49:50','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-04 10:49:50', 1, 16250, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-18 16:15:51')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-15, sellQuantity = sellQuantity-0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:15:51' ;
UPDATE buybilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240.00, meanbuyprice_withTax = 240.00, lastbuyprice_withDiscountAndTax = 240.00
                where buybilldetailid = 32156;
UPDATE product SET productName = '7185', productDescription = '', productCatId = '5', productBuyPrice = '240.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2024-12-04', conditions = '0', userId = '77', limitamount = '1', parcode = '07185',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '240',lastbuyprice_withDiscount = '0',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='0'  WHERE productId = '16250';
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16250;
UPDATE storedetail SET  productquantity = '-4', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16249';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16250', '1', '15', '1', '13940', 'حذف فاتورة مشتريات - للتعديل', 'buyBillController.php', '11', '-4', '77', '2024-12-04 10:49:50','0','0');
UPDATE supplier SET  suppliercurrentDebt = '322435',suppliercurrentDebtInCurrency= '322435' , userid = '77', supplierdate = '2024-12-18 16:15:51'   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', '329635.00', '7200.00', '1', 'حذف فاتورة مشتريات - للتعديل', '13940', '322435', '2024-12-04 10:49:50', '77', 'buyBillController.php', 'حذف فاتورة مشتريات - للتعديل', '0','', '0','1','1','7200','1','329635','7200','322435','0');
UPDATE productserial SET del = 1
		 WHERE billid = 13940;
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 ('0675017ae78861', '2024-12-04 10:51:32', '20', '322435.00', '329635', '0', '0', '7200', '7200', '0.00', '7200', '1', '2024-12-18 16:15:51', '', '77', '0', '', '1', '1','1','13940','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 ('07185', '14140', '5', '16250', '15.00', '240', '3600', '0.00', '', '2024-12-18 16:15:51', '16250','','','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-04 10:51:32', 1, 16250, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-18 16:15:51')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:15:51' ;
UPDATE product SET  productBuyPrice = "240" WHERE productId = 16250 ;
UPDATE buybilldetail SET  quantitybefore = -4 WHERE buybilldetailid = 32721 ;
UPDATE product SET productName = '7185', productDescription = '', productCatId = '5', productBuyPrice = '240.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2024-12-04', conditions = '0', userId = '77', limitamount = '1', parcode = '07185',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 = '16250';
UPDATE buybilldetail SET  lastbuyprice = 240 , meanbuyprice = 240, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 240
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32721;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16250;
UPDATE storedetail SET  productquantity = '11', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16249';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16250', '1', '15', '0', '14140', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-4', '11', '77', '2024-12-04 10:51:32','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 ('07292', '14140', '5', '16483', '15', '240', '3600', '0', '', '2024-12-18 16:15:51', '16483','','','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-04 10:51:32', 1, 16483, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-18 16:15:51')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:15:51' ;
UPDATE product SET  productBuyPrice = "240" WHERE productId = 16483 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32722 ;
UPDATE product SET productName = '7292', 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 = '07292',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 = '16483';
UPDATE buybilldetail SET  lastbuyprice = 240 , meanbuyprice = 240, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 240
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32722;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16483;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16482';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16483', '1', '15', '0', '14140', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-04 10:51:32','0','0');
DELETE FROM productserial WHERE billid = 13940
		and type =0 
		;
UPDATE supplier SET  suppliercurrentDebt = '329635',suppliercurrentDebtInCurrency= '329635' , userid = '77', supplierdate = '2024-12-18 16:15:51'   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', '322435.00', '7200', '0', 'اضافة فاتورة مشتريات', '14140', '329635', '2024-12-18 16:15:51', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','7200','1','322435','7200','329635','0');
update buybill set dailyentryid='0,' where buybillid=14140;
UPDATE product SET overAllAveragePrice = 240 WHERE productId = 16250;UPDATE product SET overAllAveragePrice = 240 WHERE productId = 16483;;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:45:52";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:15:52", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:15:52', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14140');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:45:53";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:15:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:15:54', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:47:48";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:17:48", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:17:48', '77', 'bill', '192.168.1.21', '', '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 ('7322','','5','130','180', '180','180', '2024-12-18', '0', '77', '1', '07322', '0', '0', '0', '0', '0', '130','130','130','130','130','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','130','130','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16484, 1,'2024-12-18 16:18:22',77)
                ON DUPLICATE KEY UPDATE productid = 16484, edited = 1, sysdate = '2024-12-18 16:18: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', '16484', '1', '2024-12-18', '77', '0','1648401','180','180','180','130','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16484', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16484', '1', '0', '0', '16484', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:48:34";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:18:34", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:18:34', '77', 'add', '192.168.1.21', '', '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 ('06762d98c825bd', '2024-12-18 16:17:48', '102', '180110.00', '188060', '0', '0', '7950',  '7950', '0', '7950', '1', '2024-12-18 16:18: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 ('07271', '14141', '5', '16379', '15', '160', '2400', '0', '', '2024-12-18 16:18:35', '16379','','','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-18 16:17:48', 1, 16379, 0, 0
                    , 160, 15, 0, 0, 77, '2024-12-18 16:18:35')
                ON DUPLICATE KEY UPDATE buyprice = 160,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:18:35' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16379', '160', '15', '0', 'buyBillController.php', '32723', '', '0', '0');
UPDATE product SET  productBuyPrice = "160" WHERE productId = 16379 ;
UPDATE buybilldetail SET  quantitybefore = 13 WHERE buybilldetailid = 32723 ;
UPDATE product SET productName = '7271', 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 = '07271',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 = '16379';
UPDATE buybilldetail SET  lastbuyprice = 160 , meanbuyprice = 160, lastbuyprice_withDiscount = 160, meanbuyprice_withDiscount = 160
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 160, lastbuyprice_withDiscountAndTax = 160
                where buybilldetailid = 32723;
UPDATE productunit SET proUnitBuyPrice  = 160 * productnumber WHERE productid = 16379;
UPDATE storedetail SET  productquantity = '28', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16378';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16379', '1', '15', '0', '14141', 'اضافة فاتورة مشتريات', 'buyBillController.php', '13', '28', '77', '2024-12-18 16:17: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 ('07256', '14141', '5', '16331', '15', '240', '3600', '0', '', '2024-12-18 16:18:35', '16331','','','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-18 16:17:48', 1, 16331, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-18 16:18:35')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:18:35' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16331', '240', '15', '0', 'buyBillController.php', '32724', '', '0', '0');
UPDATE product SET  productBuyPrice = "240" WHERE productId = 16331 ;
UPDATE buybilldetail SET  quantitybefore = 41 WHERE buybilldetailid = 32724 ;
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 buybilldetail SET  lastbuyprice = 240 , meanbuyprice = 240, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 240
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32724;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16331;
UPDATE storedetail SET  productquantity = '56', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16330';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16331', '1', '15', '0', '14141', 'اضافة فاتورة مشتريات', 'buyBillController.php', '41', '56', '77', '2024-12-18 16:17: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 ('07322', '14141', '5', '16484', '15', '130', '1950', '0', '', '2024-12-18 16:18:35', '16484','','','0','0','0','0','0',null,'130','1950','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-18 16:17:48', 1, 16484, 0, 0
                    , 130, 15, 0, 0, 77, '2024-12-18 16:18:35')
                ON DUPLICATE KEY UPDATE buyprice = 130,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:18:35' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16484', '130', '15', '0', 'buyBillController.php', '32725', '', '0', '0');
UPDATE product SET  productBuyPrice = "130" WHERE productId = 16484 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32725 ;
UPDATE product SET productName = '7322', productDescription = '', productCatId = '5', productBuyPrice = '130.00', productSellAllPrice = '180.00', productSellUnitPrice = '180.00', productSellHalfPrice = '180.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07322',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '130',lastbuyprice_withDiscount = '130',meanbuyprice = '130',meanbuyprice_withDiscount = '130' , productbuypricereal = '130.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='130',meanbuyprice_withTax='130',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='130'  WHERE productId = '16484';
UPDATE buybilldetail SET  lastbuyprice = 130 , meanbuyprice = 130, lastbuyprice_withDiscount = 130, meanbuyprice_withDiscount = 130
        , lastbuyprice_withTax = 130, meanbuyprice_withTax = 130, lastbuyprice_withDiscountAndTax = 130
                where buybilldetailid = 32725;
UPDATE productunit SET proUnitBuyPrice  = 130 * productnumber WHERE productid = 16484;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16483';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16484', '1', '15', '0', '14141', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 16:17:48','0','0');
UPDATE supplier SET  suppliercurrentDebt = '188060',suppliercurrentDebtInCurrency= '188060' , userid = '77', supplierdate = '2024-12-18 16:18:35'   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', '180110.00', '7950', '0', 'اضافة فاتورة مشتريات', '14141', '188060', '2024-12-18 16:17:48', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','7950','1','180110','7950','188060','0');
update buybill set dailyentryid='0,' where buybillid=14141;
COMMIT;
UPDATE product SET overAllAveragePrice = 240 WHERE productId = 16331;UPDATE product SET overAllAveragePrice = 160 WHERE productId = 16379;UPDATE product SET overAllAveragePrice = 130 WHERE productId = 16484;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:48:35";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:18:35", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:18:35', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14141');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:48:51";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:18:51", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 16:18:51', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247359
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10742,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '126' , clientdate = '2024-12-18 16:18:51', userid = '2' 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','636.00','510','1','ايصال تحصيل (( قبض من عميل ))','247359', '126', '2024-12-18 15:39:22', '2', 'clientPayedDeptController.php', '   ', '510', '0', null, '0', null, null,'', '-1','1','1','510','1','','3516','0');
UPDATE save SET  savecurrentvalue = '217973.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('217463.50','510', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247369', '217973.5', '2024-12-18 16:18:51', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '510', '510', '2024-12-18', '2', '0', '0', '2024-12-18 16:18:51','اضافة ايصال سداد للعميل روناء اسيوط 99','1','0','0','0','247369','clientPayedDeptController.php?do=show&id=247369');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122162', '-1', '510', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '510', 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 ('122162', '12551', '510', '','0');
UPDATE accountstree SET name = 'روناء اسيوط 99', customName = 'روناء اسيوط 99', customNameEn = 'روناء اسيوط 99', nameEn = 'روناء اسيوط 99', parent = '58', accountNature = '0', theValue = '-510', 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 = '636.000', clientdebtchangeamount = '510.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247359', clientdebtchangeafter = '126.000', clientdebtchangedate = '2024-12-18 15:39:22', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '510.00',discount='', reciptid='0', dailyentryid = '122162',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='510',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247369';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247359 -clientdebtchangeId = 247369
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:48:52";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:18:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 16:18: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-18 12:50:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:20:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:20:20', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762d91a34b5b
-- ----------------------------------------------------------------------------------------------------

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-18 16:15:54', '06762d91a34b5b', '1', '0.00', '0', '10', '1', '240', '230', '-230', '0', '1', '2024-12-18 16:20:20', '', '104', '0', 'نقدي','1', '0', '5', '95', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-230','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','اضافة فاتورة مردوات مبيعات','16817', '0', '2024-12-18 16:20:20', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '230', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:15:54','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 ('190.00', '06951', '16817', '5', '15850', '1', '240', '240', '0', '', '1', '0', '15850', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','240','240','0','','0');
UPDATE returnsellbilldetail 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 returnsellbilldetailid = 21999;
 INSERT INTO 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 190, 190, 190
                    , 190, 190, 190, 0, 1, 0, 0, 190, 188)
                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+250, returnSellCostBuyPrice = returnSellCostBuyPrice+190, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+190
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+190, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+190
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+190
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+190
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+190
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+188
                        , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250, 190, 190, 190
                    , 190, 190, 190, 0, 0, 190, 188)
                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+250, returnSellCostBuyPrice = returnSellCostBuyPrice+190, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+190
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+190, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+190
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+190
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+190
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+190
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+188;
UPDATE storedetail SET  productquantity = '50', userid = '104', storedetaildate = '2024-12-18 16:20:20' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '0', '16817', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '49', '50', '104', '2024-12-18 16:20:20','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '26180',  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 ('26410','-230', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16817', '26180', '2024-12-18 16:20:20', '104',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 95 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 230, 190, 190, 190
                    , 190, 190, 190 ,0, 0, 190, 188)
                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+230, returnSellCostBuyPrice = returnSellCostBuyPrice+190, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+190
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+190, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+190
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+190
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+190
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+190
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+188;
 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 230, 190, 190, 190
                    , 190, 190, 190 ,0, 0, 190, 188)
                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+230, returnSellCostBuyPrice = returnSellCostBuyPrice+190, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+190
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+190, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+190
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+190
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+190
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+190
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+188;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -230, -190, -190
                    , -190, -190, -190, -190, -190, -188)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-230, netSellCostBuyPrice = netSellCostBuyPrice+-190
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-190
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-190
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-190
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-190
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-190
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-190
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-188;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762d91a34b5b and sellbillId = 16817 and returnsellbillId = 16817
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762d12757a93
-- ----------------------------------------------------------------------------------------------------

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-18 15:41:59', '06762d12757a93', '1', '0.00', '0', '70', '1', '3640.00', '3570', '3570', '0', '1', '2024-12-18 16:20:47', '', '104', '0', 'نقدي', '1', '0', '3', '95', 'نقدي', '8' ,'0','','','','','-1','0','0','0','0','0','3570','0','','0','0','3570','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150063', '0', '2024-12-18 16:20:47', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3570', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 15:41:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35850;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1611', '150063', '14', '16259', '1', '360', '360', '0', '', '1', '2024-12-18 16:20:47', '16259', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35850-1,','1','1','0','0','360','360','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 = 548151;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16259, '2024-12-18', 353.07692307692, 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+353.07692307692, 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-18', 353.07692307692, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+353.07692307692, 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 = '9', userid = '104', storedetaildate = '2024-12-18 16:20:47' WHERE storedetailid = '16258';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16259', '1', '1', '1', '150063', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-18 16:20:47','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', '150063', '1', '16440', '1', '470', '470', '0', '', '1', '2024-12-18 16:20:47', '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 = 548152;
 INSERT INTO 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-18', 460.96153846154, 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+460.96153846154, 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-18', 460.96153846154, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460.96153846154, 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 = '41', userid = '104', storedetaildate = '2024-12-18 16:20:47' WHERE storedetailid = '16439';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16440', '1', '1', '1', '150063', 'اضافة فاتورة مبيعات', 'sellbillController.php', '42', '41', '104', '2024-12-18 16:20:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 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', '150063', '5', '16428', '1', '480', '480', '0', '', '1', '2024-12-18 16:20:47', '16428', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36345-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 = 548153;
 INSERT INTO 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-18', 470.76923076923, 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+470.76923076923, 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-18', 470.76923076923, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470.76923076923, 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 = '31', userid = '104', storedetaildate = '2024-12-18 16:20:47' WHERE storedetailid = '16427';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16428', '1', '1', '1', '150063', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32', '31', '104', '2024-12-18 16:20:47','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', '150063', '5', '16397', '1', '310', '310', '0', '', '1', '2024-12-18 16:20:47', '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 = 548154;
 INSERT INTO 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-18', 304.03846153846, 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+304.03846153846, 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-18', 304.03846153846, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+304.03846153846, 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 = '9', userid = '104', storedetaildate = '2024-12-18 16:20:47' WHERE storedetailid = '16396';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16397', '1', '1', '1', '150063', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-18 16:20:47','0','0');
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', '150063', '14', '16406', '1', '450', '450', '0', '', '1', '2024-12-18 16:20:47', '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 = 548155;
 INSERT INTO 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-18', 441.34615384615, 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+441.34615384615, 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-18', 441.34615384615, 365, 365
                    , 365, 365, 365, 365
                    , 0, 0, 0, 0
                    , 0, 0, 0, 365, 365, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+441.34615384615, 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 = '104', storedetaildate = '2024-12-18 16:20:47' WHERE storedetailid = '16405';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16406', '1', '1', '1', '150063', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '104', '2024-12-18 16:20:47','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', '150063', '14', '16318', '1', '650', '650', '0', '', '1', '2024-12-18 16:20:47', '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 = 548156;
 INSERT INTO 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-18', 637.5, 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+637.5, 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-18', 637.5, 570, 570
                    , 569, 570, 569, 570
                    , 0, 0, 0, 0
                    , 0, 0, 0, 570, 568, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+637.5, 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 = '16', userid = '104', storedetaildate = '2024-12-18 16:20:47' WHERE storedetailid = '16317';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16318', '1', '1', '1', '150063', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '104', '2024-12-18 16:20: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', '150063', '14', '16404', '1', '420', '420', '0', '', '1', '2024-12-18 16:20:47', '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 = 548157;
 INSERT INTO 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-18', 411.92307692308, 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+411.92307692308, 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-18', 411.92307692308, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+411.92307692308, 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 = '19', userid = '104', storedetaildate = '2024-12-18 16:20:47' WHERE storedetailid = '16403';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16404', '1', '1', '1', '150063', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '104', '2024-12-18 16:20:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19186;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0H891', '150063', '14', '8977', '1', '500', '500', '0', '', '1', '2024-12-18 16:20:47', '8977', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','19186-1,','1','1','0','0','500','500','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 = 548158;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8977, '2024-12-18', 490.38461538462, 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+490.38461538462, 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-18', 490.38461538462, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490.38461538462, 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 = '104', storedetaildate = '2024-12-18 16:20:47' WHERE storedetailid = '8976';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('8977', '1', '1', '1', '150063', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-18 16:20:47','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '29750',  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 ('26180','3570', '0', '1', 'اضافة فاتورة مبيعات', '150063', '29750', '2024-12-18 16:20:47', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 95 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-18', 3570, 2995, 2995
                    , 2994, 2995, 2994, 2995
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2645, 2518, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3570, sellCostBuyPrice =sellCostBuyPrice+2995
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2995, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2994
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2995, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2994
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2995
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2645
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2518
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 3570, 2995, 2995
                    , 2994, 2995, 2994, 2995
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2645, 2518, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3570, sellCostBuyPrice =sellCostBuyPrice+2995
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2995, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2994
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2995, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2994
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2995
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2645
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2518
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 3570, 2995, 2995
                    , 2994, 2995, 2994, 2995, 2645, 2518)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3570, netSellCostBuyPrice = netSellCostBuyPrice+2995
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2995
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2994
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2995
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2994
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2995
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2645
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2518;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762d12757a93 and sellbillId = 150063 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:50:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:20:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:20:48', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:52:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:22:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 16:22:13', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:52:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:22:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:22:15', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:52:53";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:22:53", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 16:22:53', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:53:15";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:23:15", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:23:15', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:53:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:23:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 16:23:34', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=add');
BEGIN;
CALL supplierInUse(82,@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 ('82', '3090.00', '1000', '1', 'ايصال دفع لمورد', '1', '2090', '2024-12-18 16:22:53', '104', 'supplierPayedDeptController.php', '', '0','1', '-1','1','1','1000','1','0','0','0','404');
UPDATE supplierdebtchange SET supplierid = '82', supplierdebtchangebefore = '3090.00', supplierdebtchangeamount = '1000', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '2090', supplierdebtchangedate = '2024-12-18 16:22:53', userid = '104', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='1000',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='3090',debtchangamountInSupplierCurrency='2090',debtchangafterInSupplierCurrency='2090', paySerialNo='404' WHERE supplierdebtchangeid = '26803';
UPDATE supplier SET  suppliercurrentDebt = '2090',suppliercurrentDebtInCurrency= '2090' , userid = '104', supplierdate = '2024-12-18 16:23:34'   WHERE supplierid = '82';
UPDATE supplier SET  inUse = 0 where supplierid = 82;
UPDATE save SET  savecurrentvalue = '28750',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('29750.00','1000', '1', '1', 'ايصال دفع لمورد', '26803', '28750', '2024-12-18 16:23:34', '104',  'supplierPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1000', '1000', '2024-12-18', '104', '0', '0', '2024-12-18 16:23:34','ايصال دفع لمورد ( نبيل جو ) ','1','0','-1','0','26803','supplierReportsController.php?do=show&id=26803');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122163', '-1', '1000', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1000', 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 ('122163', '-1', '1000', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1000', 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 = '82', supplierdebtchangebefore = '3090.00', supplierdebtchangeamount = '1000.00', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '2090.00', supplierdebtchangedate = '2024-12-18 16:22:53', userid = '104', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '122163',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='1000',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='3090',debtchangamountInSupplierCurrency='2090',debtchangafterInSupplierCurrency='2090', paySerialNo='404' WHERE supplierdebtchangeid = '26803';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:53:35";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:23:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 16:23:35', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:53:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:23:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 16:23:36', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:53:37";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:23:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 16:23:37', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:54:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:24:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:24:13', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:54:21";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:24:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 16: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 =247370
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6624,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 16:24:21', userid = '2' WHERE clientid = '6624';
UPDATE client SET  inUse = 0 where clientid = 6624;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6624','960.00','960','1','ايصال تحصيل (( قبض من عميل ))','247370', '0', '2024-12-18 16:18:52', '2', 'clientPayedDeptController.php', '   ', '960', '0', null, '0', null, null,'', '-1','1','1','960','1','','3517','0');
UPDATE save SET  savecurrentvalue = '218933.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('217973.50','960', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247372', '218933.5', '2024-12-18 16: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 ( '960', '960', '2024-12-18', '2', '0', '0', '2024-12-18 16:24:21','اضافة ايصال سداد للعميل دينا عبدالرؤوف Z17','1','0','0','0','247372','clientPayedDeptController.php?do=show&id=247372');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122164', '-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 ('122164', '-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 = '6624', clientdebtchangebefore = '960.000', clientdebtchangeamount = '960.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247370', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 16:18:52', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '960.00',discount='', reciptid='0', dailyentryid = '122164',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='960',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247372';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247370 -clientdebtchangeId = 247372
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:54:22";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:24:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 16: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-18 12:54:41";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:24:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 16:24:42', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247373
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6227,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 16:24:42', userid = '2' WHERE clientid = '6227';
UPDATE client SET  inUse = 0 where clientid = 6227;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6227','293.00','293','1','ايصال تحصيل (( قبض من عميل ))','247373', '0', '2024-12-18 16:24:22', '2', 'clientPayedDeptController.php', '   ', '293', '0', null, '0', null, null,'', '-1','1','1','293','1','','3518','0');
UPDATE save SET  savecurrentvalue = '219226.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('218933.50','293', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247373', '219226.5', '2024-12-18 16:24:42', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '293', '293', '2024-12-18', '2', '0', '0', '2024-12-18 16:24:42','اضافة ايصال سداد للعميل ام كنزي القاهرة 43','1','0','0','0','247373','clientPayedDeptController.php?do=show&id=247373');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122165', '-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 ('122165', '-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;
UPDATE clientdebtchange SET clientid = '6227', clientdebtchangebefore = '293.000', clientdebtchangeamount = '293.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247373', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 16:24:22', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '293.00',discount='', reciptid='0', dailyentryid = '122165',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='293',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247373';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:54:42";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:24:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 16:24:42', '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 ('7314','','5','140','200', '200','200', '2024-12-18', '0', '77', '1', '07314', '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 (16485, 1,'2024-12-18 16:24:45',77)
                ON DUPLICATE KEY UPDATE productid = 16485, edited = 1, sysdate = '2024-12-18 16:24: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', '16485', '1', '2024-12-18', '77', '0','1648501','200','200','200','140','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16485', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16485', '1', '0', '0', '16485', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:55:03";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:25:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 16:25:03', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247374
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3444,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 16:25:03', userid = '2' WHERE clientid = '3444';
UPDATE client SET  inUse = 0 where clientid = 3444;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3444','1020.00','1020','1','ايصال تحصيل (( قبض من عميل ))','247374', '0', '2024-12-18 16:24:42', '2', 'clientPayedDeptController.php', '   ', '1020', '0', null, '0', null, null,'', '-1','1','1','1020','1','','3519','0');
UPDATE save SET  savecurrentvalue = '220246.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('219226.50','1020', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247374', '220246.5', '2024-12-18 16:25:03', '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-18 16:25:03');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1020', '1020', '2024-12-18', '2', '0', '0', '2024-12-18 16:25:03','اضافة ايصال سداد للعميل مروة سالم','1','0','0','0','247374','clientPayedDeptController.php?do=show&id=247374');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122166', '-1', '1020', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1020', 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 ('122166', '12555', '1020', '','0');
UPDATE accountstree SET name = 'مروة سالم', customName = 'مروة سالم', customNameEn = 'مروة سالم', nameEn = 'مروة سالم', parent = '58', accountNature = '0', theValue = '-1020', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 16:25:03' WHERE id = '12555';
UPDATE clientdebtchange SET clientid = '3444', clientdebtchangebefore = '1020.000', clientdebtchangeamount = '1020.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247374', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 16:24:42', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1020.00',discount='', reciptid='0', dailyentryid = '122166',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1020',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247374';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:55:04";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:25:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 16:25:04', '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 ('7316','','5','140','200', '200','200', '2024-12-18', '0', '77', '1', '07316', '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 (16486, 1,'2024-12-18 16:25:16',77)
                ON DUPLICATE KEY UPDATE productid = 16486, edited = 1, sysdate = '2024-12-18 16:25: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', '16486', '1', '2024-12-18', '77', '0','1648601','200','200','200','140','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16486', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16486', '1', '0', '0', '16486', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE productunit SET unitid = '1', productid = '16294', productnumber = '1.00', productunitdate = '2024-12-06', userid = '77', conditions = '0',proUnitParcode='1629401',proUnitSellAllPrice='210',proUnitSellHalfPrice='210',proUnitSellUnitPrice ='210',proUnitBuyPrice='155',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16294';
UPDATE product SET productName = '7226', productDescription = '', productCatId = '5', productBuyPrice = '155', productSellAllPrice = '210', productSellUnitPrice = '210', productSellHalfPrice = '210', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '1', parcode = '07226',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155.00',lastbuyprice_withDiscount = '155',meanbuyprice = '150.5',meanbuyprice_withDiscount = '150.5' , productbuypricereal = '155' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='152.86',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='152',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 = '16294';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:56:20";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:26:20", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:26:20', '77', 'add', '192.168.1.21', '', '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 ('06762dad37f93e', '2024-12-18 16:23:15', '19', '224455.00', '264430', '0', '0', '39975',  '39975', '0', '39975', '1', '2024-12-18 16:26: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 ('07228', '14142', '5', '16348', '15', '140', '2100', '0', '', '2024-12-18 16:26:21', '16348','','','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-18 16:23:15', 1, 16348, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-18 16:26:21')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:26:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16348', '140', '15', '0', 'buyBillController.php', '32726', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16348 ;
UPDATE buybilldetail SET  quantitybefore = 20 WHERE buybilldetailid = 32726 ;
UPDATE product SET productName = '7228', 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 = '07228',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='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='139',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='140'  WHERE productId = '16348';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 139, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 139
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 139, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32726;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16348;
UPDATE storedetail SET  productquantity = '35', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16347';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16348', '1', '15', '0', '14142', 'اضافة فاتورة مشتريات', 'buyBillController.php', '20', '35', '77', '2024-12-18 16:23:15','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 ('07206', '14142', '5', '16300', '15', '140', '2100', '0', '', '2024-12-18 16:26:21', '16300','','','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-18 16:23:15', 1, 16300, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-18 16:26:21')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:26:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16300', '140', '15', '0', 'buyBillController.php', '32727', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16300 ;
UPDATE buybilldetail SET  quantitybefore = 22 WHERE buybilldetailid = 32727 ;
UPDATE product SET productName = '7206', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '1', parcode = '07206',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 = '16300';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32727;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16300;
UPDATE storedetail SET  productquantity = '37', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16299';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16300', '1', '15', '0', '14142', 'اضافة فاتورة مشتريات', 'buyBillController.php', '22', '37', '77', '2024-12-18 16:23:15','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 ('07120', '14142', '5', '16123', '15', '140', '2100', '0', '', '2024-12-18 16:26:21', '16123','','','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-18 16:23:15', 1, 16123, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-18 16:26:21')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:26:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16123', '140', '15', '0', 'buyBillController.php', '32728', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16123 ;
UPDATE buybilldetail SET  quantitybefore = 27 WHERE buybilldetailid = 32728 ;
UPDATE product SET productName = '7120', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '190.00', productSellUnitPrice = '190.00', productSellHalfPrice = '190.00', productDate = '2024-11-26', conditions = '0', userId = '77', limitamount = '1', parcode = '07120',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 = '16123';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32728;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16123;
UPDATE storedetail SET  productquantity = '42', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16122';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16123', '1', '15', '0', '14142', 'اضافة فاتورة مشتريات', 'buyBillController.php', '27', '42', '77', '2024-12-18 16:23:15','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 ('06959', '14142', '5', '15856', '15', '140', '2100', '0', '', '2024-12-18 16:26:21', '15856','','','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-18 16:23:15', 1, 15856, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-18 16:26:21')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:26:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15856', '140', '15', '0', 'buyBillController.php', '32729', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 15856 ;
UPDATE buybilldetail SET  quantitybefore = 7 WHERE buybilldetailid = 32729 ;
UPDATE product SET productName = '6959', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-11-05', conditions = '0', userId = '77', limitamount = '1', parcode = '06959',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 = '15856';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32729;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 15856;
UPDATE storedetail SET  productquantity = '22', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '15855';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15856', '1', '15', '0', '14142', 'اضافة فاتورة مشتريات', 'buyBillController.php', '7', '22', '77', '2024-12-18 16:23:15','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 ('06940', '14142', '5', '15821', '15', '140', '2100', '0', '', '2024-12-18 16:26:21', '15821','','','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-18 16:23:15', 1, 15821, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-18 16:26:21')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:26:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15821', '140', '15', '0', 'buyBillController.php', '32730', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 15821 ;
UPDATE buybilldetail SET  quantitybefore = 5 WHERE buybilldetailid = 32730 ;
UPDATE product SET productName = '6940', 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 = '06940',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '141',meanbuyprice_withDiscount = '141' , 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.25',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='142',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 = '15821';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 141, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 141
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 142, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32730;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 15821;
UPDATE storedetail SET  productquantity = '20', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '15820';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15821', '1', '15', '0', '14142', 'اضافة فاتورة مشتريات', 'buyBillController.php', '5', '20', '77', '2024-12-18 16:23:15','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', '14142', '5', '16485', '15', '140', '2100', '0', '', '2024-12-18 16:26:21', '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-18 16:23:15', 1, 16485, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-18 16:26:21')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:26:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16485', '140', '15', '0', 'buyBillController.php', '32731', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16485 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32731 ;
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='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 = '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 = 32731;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16485;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16484';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16485', '1', '15', '0', '14142', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 16:23:15','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 ('07316', '14142', '5', '16486', '15', '140', '2100', '0', '', '2024-12-18 16:26:21', '16486','','','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-18 16:23:15', 1, 16486, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-18 16:26:21')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:26:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16486', '140', '15', '0', 'buyBillController.php', '32732', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16486 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32732 ;
UPDATE product SET productName = '7316', 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 = '07316',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 = '16486';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32732;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16486;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16485';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16486', '1', '15', '0', '14142', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 16:23:15','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 ('07226', '14142', '5', '16294', '15', '155', '2325', '0', '', '2024-12-18 16:26:21', '16294','','','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-18 16:23:15', 1, 16294, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-18 16:26:21')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:26:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16294', '155', '15', '0', 'buyBillController.php', '32733', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 16294 ;
UPDATE buybilldetail SET  quantitybefore = 69 WHERE buybilldetailid = 32733 ;
UPDATE product SET productName = '7226', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '210.00', productSellUnitPrice = '210.00', productSellHalfPrice = '210.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '1', parcode = '07226',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '151',meanbuyprice_withDiscount = '151' , 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='152.86',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='153',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 = '16294';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 151, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 151
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 153, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32733;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 16294;
UPDATE storedetail SET  productquantity = '84', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '15', '0', '14142', 'اضافة فاتورة مشتريات', 'buyBillController.php', '69', '84', '77', '2024-12-18 16:23:15','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 ('07197', '14142', '5', '16297', '45', '510', '22950', '0', '', '2024-12-18 16:26:21', '16297','','','0','0','0','0','0',null,'510','22950','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-18 16:23:15', 1, 16297, 0, 0
                    , 510, 45, 0, 0, 77, '2024-12-18 16:26:21')
                ON DUPLICATE KEY UPDATE buyprice = 510,
                        buyQuantity =buyQuantity+45, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:26:21' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16297', '510', '45', '0', 'buyBillController.php', '32734', '', '0', '0');
UPDATE product SET  productBuyPrice = "510" WHERE productId = 16297 ;
UPDATE buybilldetail SET  quantitybefore = 51 WHERE buybilldetailid = 32734 ;
UPDATE product SET productName = '7197', productDescription = '', productCatId = '5', productBuyPrice = '510.00', productSellAllPrice = '580.00', productSellUnitPrice = '580.00', productSellHalfPrice = '580.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '1', parcode = '07197',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='510',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 = '16297';
UPDATE buybilldetail SET  lastbuyprice = 510 , meanbuyprice = 510, lastbuyprice_withDiscount = 510, meanbuyprice_withDiscount = 510
        , lastbuyprice_withTax = 510, meanbuyprice_withTax = 510, lastbuyprice_withDiscountAndTax = 510
                where buybilldetailid = 32734;
UPDATE productunit SET proUnitBuyPrice  = 510 * productnumber WHERE productid = 16297;
UPDATE storedetail SET  productquantity = '96', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '45', '0', '14142', 'اضافة فاتورة مشتريات', 'buyBillController.php', '51', '96', '77', '2024-12-18 16:23:15','0','0');
UPDATE supplier SET  suppliercurrentDebt = '264430',suppliercurrentDebtInCurrency= '264430' , userid = '77', supplierdate = '2024-12-18 16:26:21'   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', '224455.00', '39975', '0', 'اضافة فاتورة مشتريات', '14142', '264430', '2024-12-18 16:23:15', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','39975','1','224455','39975','264430','0');
update buybill set dailyentryid='0,' where buybillid=14142;
COMMIT;
UPDATE product SET overAllAveragePrice = 141 WHERE productId = 15821;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 15856;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16123;UPDATE product SET overAllAveragePrice = 153.12 WHERE productId = 16294;UPDATE product SET overAllAveragePrice = 510 WHERE productId = 16297;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16300;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16348;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16485;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16486;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:56:21";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:26:21", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:26:21', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14142');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:56:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:26:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:26:54', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:57:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:27:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:27:13', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=4');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:58:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:28:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:28:17', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762dbc1b8a76
-- ----------------------------------------------------------------------------------------------------

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-18 16:27:13', '06762dbc1b8a76', '1', '0.00', '0', '0', '1', '0.00', '0', '0', '0', '1', '2024-12-18 16:28:17', '', '104', '0', 'نقدي', '1', '0', '4', '0', '300', '300', 'نقدي', '1', '1', '0', '', '', '','','-1','0','0','0','','0','0','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','اضافة فاتورة مبيعات ومردودات','117', '0', '2024-12-18 16:28:17', '104', 'sellbillandruternController.php', 'اضافة فاتورة مبيعات ومردودات', '0', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:27:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35753;
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 ('250','07163', '117', '5', '16225', '1', '300', '300.00', '0', '', '0', '2024-12-18 16:28:17', '0', '16225', '0.00', '-1', '1','0','','','0','0','0','0','0','0','35753-1,','1','1','','0','0','300','300','0','','','0');
UPDATE sellandruternbilldetail 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 = 304;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16225, '2024-12-18', 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-18', 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 = '10', userid = '104', storedetaildate = '2024-12-18 16:28:17' WHERE storedetailid = '16224';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16225', '1', '1', '1', '117', 'فاتوره مبيعات ومردودات', 'sellbillandruternController.php', '11', '10', '104', '2024-12-18 16:28:17','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 ('240.00','07292', '117', '5', '16483', '1', '300', '300', '0', '', '0', '2024-12-18 16:28:17', '1', '16483', '0.00', '-1', '1','0','','','0','0','0','0','0','0','','1','1','','0','0','300','300','0','','','0');
UPDATE sellandruternbilldetail 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 = 305;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16483, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 300, 240, 240, 240
                    , 240, 240, 240, 0, 1, 0, 0, 240, 240)
                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+300, returnSellCostBuyPrice = returnSellCostBuyPrice+240, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+240
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+240, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+240
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+240
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+240
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+240
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+240
                        , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 300, 240, 240, 240
                    , 240, 240, 240, 0, 0, 240, 240)
                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+300, returnSellCostBuyPrice = returnSellCostBuyPrice+240, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+240
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+240, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+240
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+240
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+240
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+240
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+240;
UPDATE storedetail SET  productquantity = '16', userid = '104', storedetaildate = '2024-12-18 16:28:17' WHERE storedetailid = '16482';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16483', '1', '1', '0', '117', 'اضافة فاتورة مردودات مبيعات', 'sellbillandruternController.php', '15', '16', '104', '2024-12-18 16:28:17','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-18', 300, 250, 250
                    , 250, 250, 250, 250
                    , 300, 240, 240, 240
                    , 240, 240, 240 ,250, 250, 240, 240)
                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+300, returnSellCostBuyPrice = returnSellCostBuyPrice+240, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+240
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+240, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+240
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+240
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+240
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+240
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+240;
 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-18', 300, 250, 250
                    , 250, 250, 250, 250
                    , 300, 240, 240, 240
                    , 240, 240, 240 ,250, 250, 240, 240)
                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+300, returnSellCostBuyPrice = returnSellCostBuyPrice+240, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+240
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+240, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+240
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+240
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+240
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+240
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+240;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 0, 10, 10
                    , 10, 10, 10, 10, 10, 10)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+0, netSellCostBuyPrice = netSellCostBuyPrice+10
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+10
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+10
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+10
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+10
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+10
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+10
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+10;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762dbc1b8a76 and sellbillId = 117 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:58:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:28:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:28:18', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=4');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:58:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:28:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:28:28', '104', 'showDetail', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150063');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:58:34";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:28:34", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:28:34', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:58:44";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:28:44", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 16:28:44', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:59:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:29:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:29:11', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:59:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:29:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:29:13', '104', 'showDetail', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150063');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:59:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:29:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:29:22', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:59:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:29:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 16:29:24', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:59:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:29:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:29:46', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 12:59:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:29:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:29:50', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=4');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:00:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:30:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:30:10', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762dc5e44c7f
-- ----------------------------------------------------------------------------------------------------

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-18 16:29:50', '06762dc5e44c7f', '1', '0.00', '0', '0', '1', '0.00', '0', '0', '0', '1', '2024-12-18 16:30:10', '', '104', '0', 'نقدي', '1', '0', '4', '0', '300', '300', 'نقدي', '1', '1', '0', '', '', '','','-1','0','0','0','','0','0','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','اضافة فاتورة مبيعات ومردودات','118', '0', '2024-12-18 16:30:10', '104', 'sellbillandruternController.php', 'اضافة فاتورة مبيعات ومردودات', '0', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:29:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35753;
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 ('250','07163', '118', '5', '16225', '1', '300', '300.00', '0', '', '0', '2024-12-18 16:30:10', '0', '16225', '0.00', '-1', '1','0','','','0','0','0','0','0','0','35753-1,','1','1','','0','0','300','300','0','','','0');
UPDATE sellandruternbilldetail 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 = 306;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16225, '2024-12-18', 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-18', 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 = '9', userid = '104', storedetaildate = '2024-12-18 16:30:10' WHERE storedetailid = '16224';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16225', '1', '1', '1', '118', 'فاتوره مبيعات ومردودات', 'sellbillandruternController.php', '10', '9', '104', '2024-12-18 16:30:10','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 ('240.00','07292', '118', '5', '16483', '1', '300', '300', '0', '', '0', '2024-12-18 16:30:10', '1', '16483', '0.00', '-1', '1','0','','','0','0','0','0','0','0','','1','1','','0','0','300','300','0','','','0');
UPDATE sellandruternbilldetail 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 = 307;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16483, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 300, 240, 240, 240
                    , 240, 240, 240, 0, 1, 0, 0, 240, 240)
                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+300, returnSellCostBuyPrice = returnSellCostBuyPrice+240, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+240
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+240, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+240
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+240
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+240
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+240
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+240
                        , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 300, 240, 240, 240
                    , 240, 240, 240, 0, 0, 240, 240)
                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+300, returnSellCostBuyPrice = returnSellCostBuyPrice+240, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+240
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+240, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+240
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+240
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+240
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+240
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+240;
UPDATE storedetail SET  productquantity = '17', userid = '104', storedetaildate = '2024-12-18 16:30:10' WHERE storedetailid = '16482';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16483', '1', '1', '0', '118', 'اضافة فاتورة مردودات مبيعات', 'sellbillandruternController.php', '16', '17', '104', '2024-12-18 16:30:10','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-18', 300, 250, 250
                    , 250, 250, 250, 250
                    , 300, 240, 240, 240
                    , 240, 240, 240 ,250, 250, 240, 240)
                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+300, returnSellCostBuyPrice = returnSellCostBuyPrice+240, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+240
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+240, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+240
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+240
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+240
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+240
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+240;
 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-18', 300, 250, 250
                    , 250, 250, 250, 250
                    , 300, 240, 240, 240
                    , 240, 240, 240 ,250, 250, 240, 240)
                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+300, returnSellCostBuyPrice = returnSellCostBuyPrice+240, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+240
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+240, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+240
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+240
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+240
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+240
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+240;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 0, 10, 10
                    , 10, 10, 10, 10, 10, 10)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+0, netSellCostBuyPrice = netSellCostBuyPrice+10
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+10
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+10
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+10
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+10
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+10
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+10
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+10;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762dc5e44c7f and sellbillId = 118 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:00:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:30:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-18 16:30:11', '104', 'editprint', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=editprint&id=118');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:00:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:30:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 16:30:17', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:00:23";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:30:23", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:30:23', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762d7d041aa1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5780,@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-18 16:10:24', '06762d7d041aa1', '5780', '-15.00', '10342', '390', '1', '10747.00', '10357', '0', '10357', '1', '2024-12-18 16:30:23', '', '75', '0', 'اية حسين كفر الدوار 58', '2', '1', '3', '80', 'اية حسين كفر الدوار 58', '29' ,'0','','','','','-1','0','0','0','0','0','10357','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '10342', userid = '75' WHERE clientid = '5780';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5780','-15.00','10357','0','اضافة فاتورة مبيعات','150064', '10342', '2024-12-18 16:30:23', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '10357', '0', null, '0', null, null,'', '0','1','1','10357','1','2024-12-18 16:10:24','0','0');
UPDATE client SET  inUse = 0 where clientid = 5780;
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', '150064', '5', '16418', '1', '570', '570', '0', '', '1', '2024-12-18 16:30: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 = 548159;
 INSERT INTO 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-18', 549.31515771843, 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+549.31515771843, 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-18', 549.31515771843, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+549.31515771843, 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 = '3', userid = '75', storedetaildate = '2024-12-18 16:30: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', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-18 16:30:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30609;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06043', '150064', '5', '13557', '1', '400', '400', '0', '', '1', '2024-12-18 16:30:23', '13557', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30609-1,','1','1','0','0','400','400','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 = 548160;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13557, '2024-12-18', 385.48432120592, 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+385.48432120592, 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-18', 385.48432120592, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+385.48432120592, 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 = '-13', userid = '75', storedetaildate = '2024-12-18 16:30:23' WHERE storedetailid = '13556';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13557', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-12', '-13', '75', '2024-12-18 16:30:23','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', '150064', '5', '16294', '2', '210', '420', '0', '', '1', '2024-12-18 16:30:23', '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 = 548161;
 INSERT INTO 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-18', 404.75853726621, 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+404.75853726621, 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-18', 404.75853726621, 310, 310
                    , 302, 310, 302, 306.24
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 306, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+404.75853726621, 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 = '82', userid = '75', storedetaildate = '2024-12-18 16:30:23' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '2', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '84', '82', '75', '2024-12-18 16:30:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36005;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150064', '5', '15855', '1', '210', '210', '0', '', '1', '2024-12-18 16:30:24', '15855', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36005-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 = 548162;
 INSERT INTO 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-18', 202.37926863311, 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+202.37926863311, 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-18', 202.37926863311, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+202.37926863311, 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 = '25', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '15854';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15855', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '75', '2024-12-18 16:30:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35895;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150064', '14', '16292', '1', '300', '300', '0', '', '1', '2024-12-18 16:30:24', '16292', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35895-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 = 548163;
 INSERT INTO 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-18', 289.11324090444, 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+289.11324090444, 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-18', 289.11324090444, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+289.11324090444, 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 = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '16291';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16292', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31', '30', '75', '2024-12-18 16:30:24','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', '150064', '14', '16471', '1', '520', '520', '0', '', '1', '2024-12-18 16:30:24', '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 = 548164;
 INSERT INTO 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-18', 501.12961756769, 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+501.12961756769, 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-18', 501.12961756769, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+501.12961756769, 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 = '16', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '16470';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16471', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '75', '2024-12-18 16:30:24','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', '150064', '5', '16266', '1', '210', '210', '0', '', '1', '2024-12-18 16:30:24', '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 = 548165;
 INSERT INTO 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-18', 202.37926863311, 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+202.37926863311, 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-18', 202.37926863311, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+202.37926863311, 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-18 16:30:24' WHERE storedetailid = '16265';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16266', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-18 16:30:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150064', '5', '15673', '2', '360', '720', '0', '', '1', '2024-12-18 16:30:24', '15673', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36336-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, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 548166;
 INSERT INTO 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-18', 693.87177817065, 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+693.87177817065, 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-18', 693.87177817065, 590, 590
                    , 590, 590, 590, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0, 590, 590, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+693.87177817065, 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 = '37', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '15672';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15673', '1', '2', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '39', '37', '75', '2024-12-18 16:30:24','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', '150064', '5', '16355', '1', '300', '300', '0', '', '1', '2024-12-18 16:30:24', '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 = 548167;
 INSERT INTO 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-18', 289.11324090444, 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+289.11324090444, 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-18', 289.11324090444, 250, 250
                    , 245, 250, 245, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+289.11324090444, 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 = '4', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '16354';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16355', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 16:30:24','0','0');
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', '150064', '5', '16193', '1', '600', '600', '0', '', '1', '2024-12-18 16:30:24', '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 = 548168;
 INSERT INTO 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-18', 578.22648180888, 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+578.22648180888, 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-18', 578.22648180888, 530, 530
                    , 530, 530, 530, 529.75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 530, 530, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+578.22648180888, 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 = '11', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '16192';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16193', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-18 16:30:24','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', '150064', '5', '16152', '1', '240', '240', '0', '', '1', '2024-12-18 16:30:24', '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 = 548169;
 INSERT INTO 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-18', 231.29059272355, 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+231.29059272355, 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-18', 231.29059272355, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+231.29059272355, 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 = '27', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '16151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16152', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28', '27', '75', '2024-12-18 16:30:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35685;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07146', '150064', '5', '16189', '1', '220', '220', '0', '', '1', '2024-12-18 16:30:24', '16189', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35685-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 = 548170;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16189, '2024-12-18', 212.01637666325, 170, 170
                    , 170, 170, 170, 169.92
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+212.01637666325, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+169.92
                            , 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-18', 212.01637666325, 170, 170
                    , 170, 170, 170, 169.92
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+212.01637666325, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+169.92
                            , 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 = '2', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '16188';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16189', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-18 16:30:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35925;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1578', '150064', '14', '16199', '1', '580', '580', '0', '', '1', '2024-12-18 16:30:24', '16199', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35925-1,','1','1','0','0','580','580','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 = 548171;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16199, '2024-12-18', 558.95226574858, 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+558.95226574858, 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-18', 558.95226574858, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+558.95226574858, 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 = '5', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '16198';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16199', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-18 16:30:24','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', '150064', '5', '16211', '1', '230', '230', '0', '', '1', '2024-12-18 16:30:24', '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 = 548172;
 INSERT INTO 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-18', 221.6534846934, 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.6534846934, 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-18', 221.6534846934, 175, 175
                    , 175, 175, 175, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 175, 175, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+221.6534846934, 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 = '4', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '16210';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16211', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 16:30:24','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', '150064', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-18 16:30:24', '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 = 548173;
 INSERT INTO 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-18', 231.29059272355, 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+231.29059272355, 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-18', 231.29059272355, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 188, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+231.29059272355, 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 = '49', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '50', '49', '75', '2024-12-18 16:30:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35720;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1600', '150064', '14', '16216', '1', '410', '410', '0', '', '1', '2024-12-18 16:30:24', '16216', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35720-1,','1','1','0','0','410','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 355.00 , meanbuyprice = 355.00, lastbuyprice_withDiscount = 355.00, meanbuyprice_withDiscount = 355.00
        , lastbuyprice_withTax = 355, meanbuyprice_withTax = 355, lastbuyprice_withDiscountAndTax = 355
                where sellbilldetailid = 548174;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16216, '2024-12-18', 395.12142923607, 355, 355
                    , 355, 355, 355, 355
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 355, 355, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+395.12142923607, sellCostBuyPrice =sellCostBuyPrice+355
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+355, sellCostMeanBuyPrice = sellCostMeanBuyPrice+355
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+355, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+355
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+355
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+355
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+355
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 395.12142923607, 355, 355
                    , 355, 355, 355, 355
                    , 0, 0, 0, 0
                    , 0, 0, 0, 355, 355, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+395.12142923607, sellCostBuyPrice =sellCostBuyPrice+355
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+355, sellCostMeanBuyPrice = sellCostMeanBuyPrice+355
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+355, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+355
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+355
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+355
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+355
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:30:24' WHERE storedetailid = '16215';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16216', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-18 16:30:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35383;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06938', '150064', '5', '15826', '1', '530', '530', '0', '', '1', '2024-12-18 16:30:24', '15826', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35383-1,','1','1','0','0','530','530','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 445.00 , meanbuyprice = 444.00, lastbuyprice_withDiscount = 445.00, meanbuyprice_withDiscount = 444.00
        , lastbuyprice_withTax = 445, meanbuyprice_withTax = 443, lastbuyprice_withDiscountAndTax = 445
                where sellbilldetailid = 548175;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15826, '2024-12-18', 510.76672559784, 445, 445
                    , 444, 445, 444, 443.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 445, 443, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510.76672559784, sellCostBuyPrice =sellCostBuyPrice+445
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+445, sellCostMeanBuyPrice = sellCostMeanBuyPrice+444
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+445, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+444
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+443.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+445
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+443
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 510.76672559784, 445, 445
                    , 444, 445, 444, 443.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 445, 443, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510.76672559784, sellCostBuyPrice =sellCostBuyPrice+445
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+445, sellCostMeanBuyPrice = sellCostMeanBuyPrice+444
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+445, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+444
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+443.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+445
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+443
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:30:24' WHERE storedetailid = '15825';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15826', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-18 16:30:24','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', '150064', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-18 16:30:24', '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 = 548176;
 INSERT INTO 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-18', 462.5811854471, 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+462.5811854471, 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-18', 462.5811854471, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+462.5811854471, 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 = '66', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '67', '66', '75', '2024-12-18 16:30:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35740;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1481', '150064', '14', '15929', '1', '410', '410', '0', '', '1', '2024-12-18 16:30:24', '15929', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35740-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 = 548177;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15929, '2024-12-18', 395.12142923607, 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+395.12142923607, 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-18', 395.12142923607, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+395.12142923607, 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 = '1', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '15928';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15929', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-18 16:30:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36382;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07066', '150064', '5', '16069', '1', '280', '280', '0', '', '1', '2024-12-18 16:30:24', '16069', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36382-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 = 548178;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16069, '2024-12-18', 269.83902484414, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+269.83902484414, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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-18', 269.83902484414, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+269.83902484414, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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 = '29', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '16068';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16069', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '30', '29', '75', '2024-12-18 16:30:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35588;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07056', '150064', '5', '16096', '2', '600', '1200', '0', '', '1', '2024-12-18 16:30:24', '16096', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35588-2,','1','1','0','0','600','1200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 550.00 , meanbuyprice = 533.00, lastbuyprice_withDiscount = 550.00, meanbuyprice_withDiscount = 533.00
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 533, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 548179;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16096, '2024-12-18', 1156.4529636178, 1100, 1100
                    , 1066, 1100, 1066, 1100
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 1100, 1066, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1156.4529636178, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1066
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1066
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1100
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1100
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1066
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1156.4529636178, 1100, 1100
                    , 1066, 1100, 1066, 1100
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1100, 1066, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1156.4529636178, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1066
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1066
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1100
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1100
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1066
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:30:24' WHERE storedetailid = '16095';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16096', '1', '2', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '0', '75', '2024-12-18 16:30:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35764;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1560', '150064', '14', '16087', '1', '590', '590', '0', '', '1', '2024-12-18 16:30:24', '16087', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35764-1,','1','1','0','0','590','590','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 321.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 321.00
        , lastbuyprice_withTax = 310, meanbuyprice_withTax = 332, lastbuyprice_withDiscountAndTax = 310
                where sellbilldetailid = 548180;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16087, '2024-12-18', 568.58937377873, 310, 310
                    , 321, 310, 321, 365
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 310, 332, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+568.58937377873, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+321
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+321
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+365
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+332
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 568.58937377873, 310, 310
                    , 321, 310, 321, 365
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 332, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+568.58937377873, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+321
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+321
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+365
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+332
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:30:24' WHERE storedetailid = '16086';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16087', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-18 16:30:24','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', '150064', '5', '16321', '1', '310', '310', '0', '', '1', '2024-12-18 16:30:24', '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 = 548181;
 INSERT INTO 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-18', 298.75034893459, 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+298.75034893459, 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-18', 298.75034893459, 285, 285
                    , 285, 285, 285, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0, 285, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+298.75034893459, 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 = '18', userid = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '16320';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16321', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '75', '2024-12-18 16:30:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35522;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1575', '150064', '14', '16118', '1', '650', '650', '0', '', '1', '2024-12-18 16:30:24', '16118', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35522-1,','1','1','0','0','650','650','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 = 548182;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16118, '2024-12-18', 626.41202195962, 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+626.41202195962, 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-18', 626.41202195962, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+626.41202195962, 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 = '75', storedetaildate = '2024-12-18 16:30:24' WHERE storedetailid = '16117';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16118', '1', '1', '1', '150064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-18 16:30:24','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', '150064', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 16:30:24', '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', '150064', '17', '10291', '1', '107', '107', '0', '', '1', '2024-12-18 16:30:24', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','107','107','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 80 where clientid = 5780;
 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-18', 10357, 8765, 8765
                    , 8728, 8765, 8728, 8814.24
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,8270, 8240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+10357, sellCostBuyPrice =sellCostBuyPrice+8765
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8765, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8728
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8765, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8728
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+8814.24
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+8270
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+8240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (5780, '2024-12-18', 10357, 8765, 8765
                    , 8728, 8765, 8728, 8814.24
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,8270, 8240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+10357, sellCostBuyPrice =sellCostBuyPrice+8765
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8765, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8728
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8765, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8728
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+8814.24
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+8270
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+8240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 10357, 8765, 8765
                    , 8728, 8765, 8728, 8814.24, 8270, 8240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+10357, netSellCostBuyPrice = netSellCostBuyPrice+8765
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+8765
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+8728
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+8765
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+8728
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+8814.24
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+8270
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+8240;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762d7d041aa1 and sellbillId = 150064 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:00:25";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:30:25", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:30:25', '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-18 13:00:45";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:30:45", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:30:45', '75', 'showDetail', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150064');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:00:56";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:30:56", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:30: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-18 13:01:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:31:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:31:01', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762db0dacb89
-- ----------------------------------------------------------------------------------------------------

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-18 16:24:13', '06762db0dacb89', '1', '0.00', '0', '0', '1', '3205.00', '3205', '3205', '0', '1', '2024-12-18 16:31:01', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '8' ,'0','','','','','-1','0','0','0','0','0','3205','0','','0','0','3205','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150065', '0', '2024-12-18 16:31:01', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3205', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:24:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150065', '5', '16426', '2', '420', '840', '0', '', '1', '2024-12-18 16:31:01', '16426', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36340-2,','1','1','0','0','420','840','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 = 548185;
 INSERT INTO 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-18', 840, 720, 720
                    , 720, 720, 720, 720
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 720, 720, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+840, 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+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-18', 840, 720, 720
                    , 720, 720, 720, 720
                    , 0, 0, 0, 0
                    , 0, 0, 0, 720, 720, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+840, 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 = '12', userid = '104', storedetaildate = '2024-12-18 16:31:01' WHERE storedetailid = '16425';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16426', '1', '2', '1', '150065', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '12', '104', '2024-12-18 16:31:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36153;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1648', '150065', '14', '16392', '1', '660', '660', '0', '', '1', '2024-12-18 16:31:01', '16392', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36153-1,','1','1','0','0','660','660','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 = 550, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 548186;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16392, '2024-12-18', 660, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 550, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+660, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 660, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+660, sellCostBuyPrice =sellCostBuyPrice+550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:31:01' WHERE storedetailid = '16391';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16392', '1', '1', '1', '150065', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-18 16:31:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150065', '5', '16334', '2', '280', '560', '0', '', '1', '2024-12-18 16:31:02', '16334', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35989-2,','1','1','0','0','280','560','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 = 548187;
 INSERT INTO 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-18', 560, 460, 460
                    , 460, 460, 460, 460
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 460, 460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+560, 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+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-18', 560, 460, 460
                    , 460, 460, 460, 460
                    , 0, 0, 0, 0
                    , 0, 0, 0, 460, 460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+560, 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 = '25', userid = '104', storedetaildate = '2024-12-18 16:31:02' WHERE storedetailid = '16333';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16334', '1', '2', '1', '150065', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27', '25', '104', '2024-12-18 16:31:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36091;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07261', '150065', '5', '16367', '1', '580', '580', '0', '', '1', '2024-12-18 16:31:02', '16367', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36091-1,','1','1','0','0','580','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 496.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 496.00
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 499, lastbuyprice_withDiscountAndTax = 495
                where sellbilldetailid = 548188;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16367, '2024-12-18', 580, 495, 495
                    , 496, 495, 496, 497.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 495, 499, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+496
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+496
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+497.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+499
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 580, 495, 495
                    , 496, 495, 496, 497.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 499, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+496
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+496
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+497.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+499
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:31:02' WHERE storedetailid = '16366';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16367', '1', '1', '1', '150065', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '104', '2024-12-18 16:31:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36382;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07066', '150065', '5', '16069', '1', '280', '280', '0', '', '1', '2024-12-18 16:31:02', '16069', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36382-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 = 548189;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16069, '2024-12-18', 280, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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-18', 280, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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 = '28', userid = '104', storedetaildate = '2024-12-18 16:31:02' WHERE storedetailid = '16068';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16069', '1', '1', '1', '150065', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29', '28', '104', '2024-12-18 16:31:02','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', '150065', '5', '16091', '1', '285', '285', '0', '', '1', '2024-12-18 16:31:02', '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 = 548190;
 INSERT INTO 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-18', 285, 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+285, 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-18', 285, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+285, 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 = '24', userid = '104', storedetaildate = '2024-12-18 16:31:02' WHERE storedetailid = '16090';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16091', '1', '1', '1', '150065', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '104', '2024-12-18 16:31:02','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '31955',  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 ('28750','3205', '0', '1', 'اضافة فاتورة مبيعات', '150065', '31955', '2024-12-18 16:31:02', '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-18', 3205, 2680, 2680
                    , 2681, 2680, 2681, 2682.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2680, 2684, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3205, sellCostBuyPrice =sellCostBuyPrice+2680
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2680, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2681
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2680, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2681
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2682.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2680
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2684
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 3205, 2680, 2680
                    , 2681, 2680, 2681, 2682.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2680, 2684, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3205, sellCostBuyPrice =sellCostBuyPrice+2680
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2680, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2681
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2680, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2681
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2682.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2680
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2684
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 3205, 2680, 2680
                    , 2681, 2680, 2681, 2682.5, 2680, 2684)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3205, netSellCostBuyPrice = netSellCostBuyPrice+2680
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2680
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2681
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2680
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2681
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2682.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2680
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2684;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762db0dacb89 and sellbillId = 150065 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:01:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:31:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:31:02', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:01:03";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:31:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:31: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-18 13:01:14";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:31:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:31:14', '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-18 13:01:50";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:31:50", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:31:50', '2', 'editsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=149485');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:02:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:32:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:32:11', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:02:17";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:32:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:32:17', '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 = 149485 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


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

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 149485;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 16:32:18', userid = '75',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '149485';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35848;
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 = 546136;
 INSERT INTO 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-18', 252.88043478261, 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-252.88043478261, 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-18', 252.88043478261, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-252.88043478261, 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 = '14', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16256';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16257', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '13', '14', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35975;
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 = 546137;
 INSERT INTO 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-18', 327.80797101449, 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-327.80797101449, 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-18', 327.80797101449, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-327.80797101449, 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 = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16321';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16322', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '30', '31', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-2 where id = 35938;
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 = 546138;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16186, '2024-12-18', 711.8115942029, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 620, 620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-711.8115942029, sellCostBuyPrice =sellCostBuyPrice-620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-620, sellCostMeanBuyPrice = sellCostMeanBuyPrice-620
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-620
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-620
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-620
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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-18', 711.8115942029, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0, 620, 620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-711.8115942029, sellCostBuyPrice =sellCostBuyPrice-620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-620, sellCostMeanBuyPrice = sellCostMeanBuyPrice-620
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-620
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-620
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-620
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 16:32:18' WHERE storedetailid = '16185';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16186', '1', '2', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '18', '20', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36335;
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 = 546139;
 INSERT INTO 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-18', 234.14855072464, 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-234.14855072464, 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-18', 234.14855072464, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-234.14855072464, 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 = '18', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16423';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16424', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '17', '18', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35177;
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
        , lastbuyprice_withTax = 410, meanbuyprice_withTax = 247, lastbuyprice_withDiscountAndTax = 410
                where sellbilldetailid = 546140;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15867, '2024-12-18', 468.29710144928, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 410, 247, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-468.29710144928, sellCostBuyPrice =sellCostBuyPrice-410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-410, sellCostMeanBuyPrice = sellCostMeanBuyPrice-410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-247
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 468.29710144928, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 247, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-468.29710144928, sellCostBuyPrice =sellCostBuyPrice-410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-410, sellCostMeanBuyPrice = sellCostMeanBuyPrice-410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-247
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 16:32:18' WHERE storedetailid = '15866';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15867', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '11', '12', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36008;
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 = 546141;
 INSERT INTO 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-18', 515.1268115942, 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-515.1268115942, 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-18', 515.1268115942, 425, 425
                    , 425, 425, 425, 425
                    , 0, 0, 0, 0
                    , 0, 0, 0, 425, 213, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-515.1268115942, 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 = '12', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16340', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '11', '12', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-2 where id = 35968;
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 = 546142;
 INSERT INTO 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-18', 1517.2826086957, 1460, 1460
                    , 1460, 1460, 1460, 1460
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 1460, 1460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1517.2826086957, sellCostBuyPrice =sellCostBuyPrice-1460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1460, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1460
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1460
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1460
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1460
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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-18', 1517.2826086957, 1460, 1460
                    , 1460, 1460, 1460, 1460
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1460, 1460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1517.2826086957, sellCostBuyPrice =sellCostBuyPrice-1460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1460, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1460
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1460
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1460
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1460
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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 = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '2', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '53', '55', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36029;
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 293.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 293.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 293, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 546143;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16345, '2024-12-18', 327.80797101449, 295, 295
                    , 293, 295, 293, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 295, 293, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-327.80797101449, sellCostBuyPrice =sellCostBuyPrice-295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-295, sellCostMeanBuyPrice = sellCostMeanBuyPrice-293
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-293
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-293
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 327.80797101449, 295, 295
                    , 293, 295, 293, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 293, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-327.80797101449, sellCostBuyPrice =sellCostBuyPrice-295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-295, sellCostMeanBuyPrice = sellCostMeanBuyPrice-293
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-293
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-293
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 16:32:18' WHERE storedetailid = '16344';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16345', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '8', '9', '2', '2024-12-14 14:00:04','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 = 546144;
 INSERT INTO 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-18', 187.31884057971, 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-187.31884057971, 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-18', 187.31884057971, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-187.31884057971, 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 = '16', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16434';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16435', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '15', '16', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36055;
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 = 546145;
 INSERT INTO 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-18', 196.6847826087, 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-196.6847826087, 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-18', 196.6847826087, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-196.6847826087, 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 = '83', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '82', '83', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35451;
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 = 546146;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16061, '2024-12-18', 266.92934782609, 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-266.92934782609, 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-18', 266.92934782609, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-266.92934782609, 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 = '6', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16060';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16061', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '5', '6', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35803;
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 = 546147;
 INSERT INTO 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-18', 234.14855072464, 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-234.14855072464, 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-18', 234.14855072464, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-234.14855072464, 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 = '28', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16152', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '27', '28', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 34037;
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        
                where sellbilldetailid = 546148;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15356, '2024-12-18', 196.6847826087, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-196.6847826087, sellCostBuyPrice =sellCostBuyPrice-150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-150, sellCostMeanBuyPrice = sellCostMeanBuyPrice-150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-150
                            , 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-18', 196.6847826087, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-196.6847826087, sellCostBuyPrice =sellCostBuyPrice-150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-150, sellCostMeanBuyPrice = sellCostMeanBuyPrice-150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-150
                            , 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 = '2', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '15355';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15356', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '1', '2', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35892;
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 = 546149;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16069, '2024-12-18', 262.24637681159, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-262.24637681159, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220
                            , 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-18', 262.24637681159, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-262.24637681159, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220
                            , 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 = '29', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16068';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16069', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '28', '29', '2', '2024-12-14 14:00:04','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 532.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 532.00
        
                where sellbilldetailid = 546150;
 INSERT INTO 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-18', 421.46739130435, 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-421.46739130435, 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-18', 421.46739130435, 380, 380
                    , 532, 380, 532, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-421.46739130435, 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 = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '13801';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13802', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0', '1', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35382;
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
        , lastbuyprice_withTax = 320, meanbuyprice_withTax = 320, lastbuyprice_withDiscountAndTax = 320
                where sellbilldetailid = 546151;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15814, '2024-12-18', 360.58876811594, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-360.58876811594, 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-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 360.58876811594, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-360.58876811594, 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 = '6', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '15813';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15814', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '5', '6', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35374;
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 = 546152;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16031, '2024-12-18', 374.63768115942, 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-374.63768115942, 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-18', 374.63768115942, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-374.63768115942, 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 = '1', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16030';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16031', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0', '1', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35922;
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 = 546153;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16299, '2024-12-18', 187.31884057971, 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-187.31884057971, 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-18', 187.31884057971, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-187.31884057971, 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 = '13', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16298';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16299', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '12', '13', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35149;
UPDATE sellbilldetail SET  lastbuyprice = 125.00 , meanbuyprice = 125.00, lastbuyprice_withDiscount = 125.00, meanbuyprice_withDiscount = 125.00
        , lastbuyprice_withTax = 125, meanbuyprice_withTax = 125, lastbuyprice_withDiscountAndTax = 125
                where sellbilldetailid = 546154;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15919, '2024-12-18', 149.85507246377, 125, 125
                    , 125, 125, 125, 125
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 125, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-149.85507246377, sellCostBuyPrice =sellCostBuyPrice-125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-125, sellCostMeanBuyPrice = sellCostMeanBuyPrice-125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-125
                            , 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-18', 149.85507246377, 125, 125
                    , 125, 125, 125, 125
                    , 0, 0, 0, 0
                    , 0, 0, 0, 125, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-149.85507246377, sellCostBuyPrice =sellCostBuyPrice-125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-125, sellCostMeanBuyPrice = sellCostMeanBuyPrice-125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-125
                            , 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 = '8', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '15918';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15919', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '7', '8', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 34038;
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        
                where sellbilldetailid = 546155;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15285, '2024-12-18', 309.07608695652, 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-309.07608695652, 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-18', 309.07608695652, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-309.07608695652, 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 = '8', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '15284';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15285', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '7', '8', '2', '2024-12-14 14:00:04','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 546156;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10357, '2024-12-18', 234.14855072464, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-234.14855072464, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , 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-18', 234.14855072464, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-234.14855072464, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , 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 = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '10356';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10357', '1', '1', '0', '149485', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-8', '-7', '2', '2024-12-14 14:00:04','0','0');
CALL clientInUse(3828,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '98392', userid = '2' WHERE clientid = '3828';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3828','106147.00','7755.00','1','تعديل فاتورة مبيعات','149485', '98392', '2024-12-14 14:00:04', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '7755', '0', null, '0', null, null,'', '0','1','1','7755','1','2024-12-14 14:00:04','0','0');
UPDATE client SET  inUse = 0 where clientid = 3828;
 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-18', 7755, 6785, 6785
                    , 6931, 6785, 6931, 6533.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,5740, 5361, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-7755, sellCostBuyPrice =sellCostBuyPrice-6785
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-6785, sellCostMeanBuyPrice = sellCostMeanBuyPrice-6931
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-6785, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-6931
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-6533.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-5740
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-5361
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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 (3828, '2024-12-18', 7755, 6785, 6785
                    , 6931, 6785, 6931, 6533.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 5740, 5361, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-7755, sellCostBuyPrice =sellCostBuyPrice-6785
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-6785, sellCostMeanBuyPrice = sellCostMeanBuyPrice-6931
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-6785, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-6931
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-6533.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-5740
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-5361
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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, 7755, 6785, 6785
                    , 6931, 6785, 6931, 6533.12, 5740, 5361)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-7755, netSellCostBuyPrice = netSellCostBuyPrice-6785
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-6785
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-6931
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-6785
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-6931
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-6533.12
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-5740
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-5361;

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


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

COMMIT;
BEGIN;
CALL clientInUse(3828,@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-14 14:00:04', '0675d734423c10', '3828', '98392.00', '106422', '550', '1', '8580', '8030', '0', '8030', '1', '2024-12-14 14:00:04', '', '2', '0', 'جريتو 52', '2', '1', '3', '90', 'جريتو 52', '25', '149485', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-14','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '106422', userid = '2' WHERE clientid = '3828';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3828','98392.00','8030','0','اضافة فاتورة مبيعات (معدله)','150066', '106422', '2024-12-18 16:32:18', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '8030', '0', null, '0', null, null,'', '0','1','1','7755','1','2024-12-14 14:00:04','0','0');
UPDATE client SET  inUse = 0 where clientid = 3828;
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', '150066', '14', '16257', '1', '270', '270', '0', '', '1', '2024-12-18 16:32:18', '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 = 548191;
 INSERT INTO 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-18', 252.69230769231, 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+252.69230769231, 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-18', 252.69230769231, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+252.69230769231, 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 = '13', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16256';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16257', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '14', '13', '2', '2024-12-18 16:32:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35975;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150066', '1', '16322', '1', '350', '350', '0', '', '1', '2024-12-18 16:32:18', '16322', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35975-1,','1','1','0','0','350','350','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 = 548192;
 INSERT INTO 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-18', 327.5641025641, 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+327.5641025641, 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-18', 327.5641025641, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+327.5641025641, 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 = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16321';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16322', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '31', '30', '2', '2024-12-18 16:32:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35938;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3318', '150066', '1', '16186', '2', '380', '760', '0', '', '1', '2024-12-18 16:32:18', '16186', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35938-2,','1','1','0','0','380','760','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 = 548193;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16186, '2024-12-18', 711.28205128205, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 620, 620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+711.28205128205, sellCostBuyPrice =sellCostBuyPrice+620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+620, sellCostMeanBuyPrice = sellCostMeanBuyPrice+620
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+620
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+620
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+620
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 711.28205128205, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0, 620, 620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+711.28205128205, sellCostBuyPrice =sellCostBuyPrice+620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+620, sellCostMeanBuyPrice = sellCostMeanBuyPrice+620
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+620
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+620
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+620
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:32:18' WHERE storedetailid = '16185';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16186', '1', '2', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '20', '18', '2', '2024-12-18 16:32:18','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', '150066', '14', '16424', '1', '250', '250', '0', '', '1', '2024-12-18 16:32:18', '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 = 548194;
 INSERT INTO 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-18', 233.97435897436, 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+233.97435897436, 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-18', 233.97435897436, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+233.97435897436, 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 = '17', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16423';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16424', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '18', '17', '2', '2024-12-18 16:32:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35177;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3282', '150066', '1', '15867', '1', '500', '500', '0', '', '1', '2024-12-18 16:32:18', '15867', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35177-1,','1','1','0','0','500','500','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 = 247, lastbuyprice_withDiscountAndTax = 410
                where sellbilldetailid = 548195;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15867, '2024-12-18', 467.94871794872, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 410, 247, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+467.94871794872, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+247
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 467.94871794872, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 247, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+467.94871794872, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+247
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:32:18' WHERE storedetailid = '15866';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15867', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '12', '11', '2', '2024-12-18 16:32:18','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', '150066', '14', '16340', '1', '550', '550', '0', '', '1', '2024-12-18 16:32:18', '16340', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36008-1,','1','1','0','0','550','550','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 = 548196;
 INSERT INTO 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-18', 514.74358974359, 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+514.74358974359, 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-18', 514.74358974359, 425, 425
                    , 425, 425, 425, 425
                    , 0, 0, 0, 0
                    , 0, 0, 0, 425, 213, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+514.74358974359, 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 = '11', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16340', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '12', '11', '2', '2024-12-18 16:32:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35968;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150066', '5', '16205', '2', '810', '1620', '0', '', '1', '2024-12-18 16:32:18', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35968-2,','1','1','0','0','810','1620','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 = 548197;
 INSERT INTO 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-18', 1516.1538461538, 1460, 1460
                    , 1460, 1460, 1460, 1460
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 1460, 1460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1516.1538461538, sellCostBuyPrice =sellCostBuyPrice+1460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1460
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1460
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1460
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1460
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1516.1538461538, 1460, 1460
                    , 1460, 1460, 1460, 1460
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1460, 1460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1516.1538461538, sellCostBuyPrice =sellCostBuyPrice+1460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1460
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1460
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1460
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1460
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '2', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '55', '53', '2', '2024-12-18 16:32:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36029;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07210', '150066', '5', '16345', '1', '350', '350', '0', '', '1', '2024-12-18 16:32:18', '16345', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36029-1,','1','1','0','0','350','350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 293.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 293.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 293, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 548198;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16345, '2024-12-18', 327.5641025641, 295, 295
                    , 293, 295, 293, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 293, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+327.5641025641, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+293
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+293
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+293
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 327.5641025641, 295, 295
                    , 293, 295, 293, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 293, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+327.5641025641, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+293
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+293
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+293
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:32:18' WHERE storedetailid = '16344';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16345', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '9', '8', '2', '2024-12-18 16:32:18','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', '150066', '5', '16435', '1', '200', '200', '0', '', '1', '2024-12-18 16:32:18', '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 = 548199;
 INSERT INTO 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-18', 187.17948717949, 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+187.17948717949, 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-18', 187.17948717949, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+187.17948717949, 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 = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16434';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16435', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '16', '15', '2', '2024-12-18 16:32:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36055;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150066', '5', '16294', '1', '210', '210', '0', '', '1', '2024-12-18 16:32:18', '16294', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36055-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 = 548200;
 INSERT INTO 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-18', 196.53846153846, 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+196.53846153846, 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-18', 196.53846153846, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+196.53846153846, 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 = '82', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '83', '82', '2', '2024-12-18 16:32:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35451;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07078', '150066', '5', '16061', '1', '285', '285', '0', '', '1', '2024-12-18 16:32:18', '16061', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35451-1,','1','1','0','0','285','285','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 = 548201;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16061, '2024-12-18', 266.73076923077, 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+266.73076923077, 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-18', 266.73076923077, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+266.73076923077, 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 = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16060';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16061', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '6', '5', '2', '2024-12-18 16:32:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35803;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150066', '5', '16152', '1', '250', '250', '0', '', '1', '2024-12-18 16:32:18', '16152', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35803-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
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 548202;
 INSERT INTO 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-18', 233.97435897436, 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+233.97435897436, 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-18', 233.97435897436, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+233.97435897436, 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 = '27', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '16151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16152', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '28', '27', '2', '2024-12-18 16:32:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34037;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3188', '150066', '1', '15356', '1', '210', '210', '0', '', '1', '2024-12-18 16:32:18', '15356', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34037-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
        
                where sellbilldetailid = 548203;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15356, '2024-12-18', 196.53846153846, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+196.53846153846, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , 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-18', 196.53846153846, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+196.53846153846, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , 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 = '1', userid = '2', storedetaildate = '2024-12-18 16:32:18' WHERE storedetailid = '15355';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15356', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '2', '1', '2', '2024-12-18 16:32:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35892;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07066', '150066', '5', '16069', '1', '280', '280', '0', '', '1', '2024-12-18 16:32:19', '16069', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35892-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 = 548204;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16069, '2024-12-18', 262.05128205128, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+262.05128205128, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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-18', 262.05128205128, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+262.05128205128, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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 = '28', userid = '2', storedetaildate = '2024-12-18 16:32:19' WHERE storedetailid = '16068';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16069', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '29', '28', '2', '2024-12-18 16:32:19','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', '150066', '5', '13802', '1', '450', '450', '0', '', '1', '2024-12-18 16:32:19', '13802', '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 = 380.00 , meanbuyprice = 532.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 532.00
        
                where sellbilldetailid = 548205;
 INSERT INTO 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-18', 421.15384615385, 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+421.15384615385, 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-18', 421.15384615385, 380, 380
                    , 532, 380, 532, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+421.15384615385, 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 = '0', userid = '2', storedetaildate = '2024-12-18 16:32:19' WHERE storedetailid = '13801';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13802', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '1', '0', '2', '2024-12-18 16:32:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35382;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3276', '150066', '1', '15814', '1', '385', '385', '0', '', '1', '2024-12-18 16:32:19', '15814', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35382-1,','1','1','0','0','385','385','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 = 320, lastbuyprice_withDiscountAndTax = 320
                where sellbilldetailid = 548206;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15814, '2024-12-18', 360.32051282051, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360.32051282051, 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+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 360.32051282051, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360.32051282051, 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 = '5', userid = '2', storedetaildate = '2024-12-18 16:32:19' WHERE storedetailid = '15813';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15814', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '6', '5', '2', '2024-12-18 16:32:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35374;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1528', '150066', '14', '16031', '1', '400', '400', '0', '', '1', '2024-12-18 16:32:19', '16031', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35374-1,','1','1','0','0','400','400','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 = 548207;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16031, '2024-12-18', 374.35897435897, 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+374.35897435897, 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-18', 374.35897435897, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+374.35897435897, 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 = '0', userid = '2', storedetaildate = '2024-12-18 16:32:19' WHERE storedetailid = '16030';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16031', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '1', '0', '2', '2024-12-18 16:32:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35922;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07199', '150066', '5', '16299', '1', '200', '200', '0', '', '1', '2024-12-18 16:32:19', '16299', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35922-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 = 548208;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16299, '2024-12-18', 187.17948717949, 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+187.17948717949, 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-18', 187.17948717949, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+187.17948717949, 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 = '2', storedetaildate = '2024-12-18 16:32:19' WHERE storedetailid = '16298';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16299', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '13', '12', '2', '2024-12-18 16:32:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35149;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3295', '150066', '1', '15919', '1', '160', '160', '0', '', '1', '2024-12-18 16:32:19', '15919', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35149-1,','1','1','0','0','160','160','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
        , lastbuyprice_withTax = 125, meanbuyprice_withTax = 125, lastbuyprice_withDiscountAndTax = 125
                where sellbilldetailid = 548209;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15919, '2024-12-18', 149.74358974359, 125, 125
                    , 125, 125, 125, 125
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 125, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+149.74358974359, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+125
                            , 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-18', 149.74358974359, 125, 125
                    , 125, 125, 125, 125
                    , 0, 0, 0, 0
                    , 0, 0, 0, 125, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+149.74358974359, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+125
                            , 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 = '7', userid = '2', storedetaildate = '2024-12-18 16:32:19' WHERE storedetailid = '15918';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15919', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '8', '7', '2', '2024-12-18 16:32:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34038;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3168', '150066', '1', '15285', '1', '330', '330', '0', '', '1', '2024-12-18 16:32:19', '15285', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34038-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
        
                where sellbilldetailid = 548210;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15285, '2024-12-18', 308.84615384615, 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+308.84615384615, 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-18', 308.84615384615, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+308.84615384615, 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 = '7', userid = '2', storedetaildate = '2024-12-18 16:32:19' WHERE storedetailid = '15284';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15285', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '8', '7', '2', '2024-12-18 16:32:19','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','عرض 250', '150066', '18', '10357', '1', '250', '250', '0', '', '1', '2024-12-18 16:32:19', '10357', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','250','250','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 = 548211;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10357, '2024-12-18', 233.97435897436, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+233.97435897436, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , 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-18', 233.97435897436, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+233.97435897436, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , 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 = '-8', userid = '2', storedetaildate = '2024-12-18 16:32:19' WHERE storedetailid = '10356';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10357', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '-7', '-8', '2', '2024-12-18 16:32:19','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', '150066', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 16:32:19', '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');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36490;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07292', '150066', '5', '16483', '1', '300', '300', '0', '', '1', '2024-12-18 16:32:19', '16483', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36490-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 = 548213;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16483, '2024-12-18', 280.76923076923, 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+280.76923076923, 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-18', 280.76923076923, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280.76923076923, 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 = '16', userid = '2', storedetaildate = '2024-12-18 16:32:19' WHERE storedetailid = '16482';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16483', '1', '1', '1', '150066', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '17', '16', '2', '2024-12-18 16: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-18', 8030, 7025, 7025
                    , 7171, 7025, 7171, 6773.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,5980, 5601, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8030, sellCostBuyPrice =sellCostBuyPrice+7025
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7025, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7171
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7025, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7171
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6773.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+5980
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5601
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (3828, '2024-12-18', 8030, 7025, 7025
                    , 7171, 7025, 7171, 6773.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,5980, 5601, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8030, sellCostBuyPrice =sellCostBuyPrice+7025
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7025, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7171
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7025, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7171
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6773.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+5980
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5601
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 8030, 7025, 7025
                    , 7171, 7025, 7171, 6773.12, 5980, 5601)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+8030, netSellCostBuyPrice = netSellCostBuyPrice+7025
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+7025
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+7171
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+7025
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+7171
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+6773.12
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+5980
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+5601;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 149485 and newid=150066 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:02:20";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:32:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:32:20', '2', 'editprint', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150066');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:03:11";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:33:11", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 16:33:11', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:03:18";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:33:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 16:33:18', '2', 'show', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.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 ('H1525','','14','700','900', '900','900', '2024-12-18', '0', '77', '1', 'H1525', '0', '0', '0', '0', '0', '700','700','700','700','700','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','700','700','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16487, 1,'2024-12-18 16:33:21',77)
                ON DUPLICATE KEY UPDATE productid = 16487, edited = 1, sysdate = '2024-12-18 16:33: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', '16487', '1', '2024-12-18', '77', '0','1648701','900','900','900','700','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16487', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16487', '1', '0', '0', '16487', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:03:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:33:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:33:39', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762dcebd1c57
-- ----------------------------------------------------------------------------------------------------

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-18 16:32:11', '06762dcebd1c57', '1', '0.00', '0', '0', '1', '980', '980', '-980', '0', '1', '2024-12-18 16:33:39', '', '104', '0', 'نقدي','1', '0', '5', '4', 'نقدي', '1', '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 = '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','اضافة فاتورة مردوات مبيعات','16818', '0', '2024-12-18 16:33:39', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '980', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:32: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 ('815.00', 'H1515', '16818', '14', '16033', '1', '980', '980', '0', '', '1', '0', '16033', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','980','980','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 815.00 , meanbuyprice = 815.00, lastbuyprice_withDiscount = 815.00, meanbuyprice_withDiscount = 815.00
        , lastbuyprice_withTax = 815, meanbuyprice_withTax = 815, lastbuyprice_withDiscountAndTax = 815
                where returnsellbilldetailid = 22000;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16033, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 980, 815, 815, 815
                    , 815, 815, 815, 0, 1, 0, 0, 815, 815)
                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+815, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+815
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+815, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+815
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+815
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+815
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+815
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+815
                        , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 980, 815, 815, 815
                    , 815, 815, 815, 0, 0, 815, 815)
                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+815, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+815
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+815, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+815
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+815
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+815
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+815
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+815;
UPDATE storedetail SET  productquantity = '5', userid = '104', storedetaildate = '2024-12-18 16:33:39' WHERE storedetailid = '16032';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16033', '1', '1', '0', '16818', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '4', '5', '104', '2024-12-18 16:33:39','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '30975',  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 ('31955','-980', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16818', '30975', '2024-12-18 16:33:39', '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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 980, 815, 815, 815
                    , 815, 815, 815 ,0, 0, 815, 815)
                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+815, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+815
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+815, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+815
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+815
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+815
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+815
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+815;
 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 980, 815, 815, 815
                    , 815, 815, 815 ,0, 0, 815, 815)
                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+815, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+815
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+815, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+815
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+815
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+815
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+815
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+815;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -980, -815, -815
                    , -815, -815, -815, -815, -815, -815)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-980, netSellCostBuyPrice = netSellCostBuyPrice+-815
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-815
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-815
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-815
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-815
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-815
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-815
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-815;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762dcebd1c57 and sellbillId = 16818 and returnsellbillId = 16818
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:03:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:33:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:33:39', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:03:57";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:33:57", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 16:33:57', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:03:59";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:33:59", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:33:59', '2', 'editsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=149485');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:04:01";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:34:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:34: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-18 13:04:08";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:34:08", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:34: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-18 13:04:15";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:34:15", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 16:34:15', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:04:17";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:34:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:34:17', '2', 'editsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150066');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:04:35";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:34:35", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:34:35', '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 = 150066 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


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

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150066;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 16:34:35', userid = '2',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '150066';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35848;
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 = 548191;
 INSERT INTO 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-18', 252.69230769231, 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-252.69230769231, 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-18', 252.69230769231, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-252.69230769231, 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 = '14', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16256';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16257', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '13', '14', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35975;
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 = 548192;
 INSERT INTO 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-18', 327.5641025641, 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-327.5641025641, 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-18', 327.5641025641, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-327.5641025641, 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 = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16321';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16322', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '30', '31', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-2 where id = 35938;
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 = 548193;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16186, '2024-12-18', 711.28205128205, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 620, 620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-711.28205128205, sellCostBuyPrice =sellCostBuyPrice-620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-620, sellCostMeanBuyPrice = sellCostMeanBuyPrice-620
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-620
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-620
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-620
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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-18', 711.28205128205, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0, 620, 620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-711.28205128205, sellCostBuyPrice =sellCostBuyPrice-620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-620, sellCostMeanBuyPrice = sellCostMeanBuyPrice-620
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-620
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-620
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-620
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 16:34:35' WHERE storedetailid = '16185';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16186', '1', '2', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '18', '20', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36335;
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 = 548194;
 INSERT INTO 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-18', 233.97435897436, 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-233.97435897436, 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-18', 233.97435897436, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-233.97435897436, 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 = '18', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16423';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16424', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '17', '18', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35177;
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
        , lastbuyprice_withTax = 410, meanbuyprice_withTax = 247, lastbuyprice_withDiscountAndTax = 410
                where sellbilldetailid = 548195;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15867, '2024-12-18', 467.94871794872, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 410, 247, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-467.94871794872, sellCostBuyPrice =sellCostBuyPrice-410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-410, sellCostMeanBuyPrice = sellCostMeanBuyPrice-410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-247
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 467.94871794872, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 247, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-467.94871794872, sellCostBuyPrice =sellCostBuyPrice-410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-410, sellCostMeanBuyPrice = sellCostMeanBuyPrice-410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-247
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 16:34:35' WHERE storedetailid = '15866';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15867', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '11', '12', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36008;
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 = 548196;
 INSERT INTO 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-18', 514.74358974359, 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-514.74358974359, 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-18', 514.74358974359, 425, 425
                    , 425, 425, 425, 425
                    , 0, 0, 0, 0
                    , 0, 0, 0, 425, 213, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-514.74358974359, 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 = '12', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16340', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '11', '12', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-2 where id = 35968;
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 = 548197;
 INSERT INTO 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-18', 1516.1538461538, 1460, 1460
                    , 1460, 1460, 1460, 1460
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 1460, 1460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1516.1538461538, sellCostBuyPrice =sellCostBuyPrice-1460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1460, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1460
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1460
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1460
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1460
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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-18', 1516.1538461538, 1460, 1460
                    , 1460, 1460, 1460, 1460
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1460, 1460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1516.1538461538, sellCostBuyPrice =sellCostBuyPrice-1460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1460, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1460
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1460
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1460
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1460
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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 = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '2', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '53', '55', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36029;
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 293.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 293.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 293, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 548198;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16345, '2024-12-18', 327.5641025641, 295, 295
                    , 293, 295, 293, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 295, 293, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-327.5641025641, sellCostBuyPrice =sellCostBuyPrice-295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-295, sellCostMeanBuyPrice = sellCostMeanBuyPrice-293
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-293
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-293
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 327.5641025641, 295, 295
                    , 293, 295, 293, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 293, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-327.5641025641, sellCostBuyPrice =sellCostBuyPrice-295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-295, sellCostMeanBuyPrice = sellCostMeanBuyPrice-293
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-293
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-293
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 16:34:35' WHERE storedetailid = '16344';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16345', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '8', '9', '2', '2024-12-14 14:00:04','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 = 548199;
 INSERT INTO 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-18', 187.17948717949, 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-187.17948717949, 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-18', 187.17948717949, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-187.17948717949, 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 = '16', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16434';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16435', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '15', '16', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36055;
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 = 548200;
 INSERT INTO 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-18', 196.53846153846, 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-196.53846153846, 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-18', 196.53846153846, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-196.53846153846, 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 = '83', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '82', '83', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35451;
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 = 548201;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16061, '2024-12-18', 266.73076923077, 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-266.73076923077, 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-18', 266.73076923077, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-266.73076923077, 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 = '6', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16060';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16061', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '5', '6', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35803;
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 = 548202;
 INSERT INTO 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-18', 233.97435897436, 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-233.97435897436, 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-18', 233.97435897436, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-233.97435897436, 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 = '28', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16152', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '27', '28', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 34037;
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        
                where sellbilldetailid = 548203;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15356, '2024-12-18', 196.53846153846, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-196.53846153846, sellCostBuyPrice =sellCostBuyPrice-150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-150, sellCostMeanBuyPrice = sellCostMeanBuyPrice-150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-150
                            , 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-18', 196.53846153846, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-196.53846153846, sellCostBuyPrice =sellCostBuyPrice-150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-150, sellCostMeanBuyPrice = sellCostMeanBuyPrice-150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-150
                            , 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 = '2', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '15355';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15356', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '1', '2', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35892;
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 = 548204;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16069, '2024-12-18', 262.05128205128, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-262.05128205128, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220
                            , 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-18', 262.05128205128, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-262.05128205128, sellCostBuyPrice =sellCostBuyPrice-220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-220, sellCostMeanBuyPrice = sellCostMeanBuyPrice-220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-220
                            , 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 = '29', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16068';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16069', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '28', '29', '2', '2024-12-14 14:00:04','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 532.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 532.00
        
                where sellbilldetailid = 548205;
 INSERT INTO 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-18', 421.15384615385, 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-421.15384615385, 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-18', 421.15384615385, 380, 380
                    , 532, 380, 532, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-421.15384615385, 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 = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '13801';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13802', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0', '1', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35382;
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
        , lastbuyprice_withTax = 320, meanbuyprice_withTax = 320, lastbuyprice_withDiscountAndTax = 320
                where sellbilldetailid = 548206;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15814, '2024-12-18', 360.32051282051, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-360.32051282051, 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-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 360.32051282051, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-360.32051282051, 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 = '6', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '15813';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15814', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '5', '6', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35374;
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 = 548207;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16031, '2024-12-18', 374.35897435897, 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-374.35897435897, 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-18', 374.35897435897, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-374.35897435897, 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 = '1', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16030';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16031', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0', '1', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35922;
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 = 548208;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16299, '2024-12-18', 187.17948717949, 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-187.17948717949, 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-18', 187.17948717949, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-187.17948717949, 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 = '13', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16298';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16299', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '12', '13', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35149;
UPDATE sellbilldetail SET  lastbuyprice = 125.00 , meanbuyprice = 125.00, lastbuyprice_withDiscount = 125.00, meanbuyprice_withDiscount = 125.00
        , lastbuyprice_withTax = 125, meanbuyprice_withTax = 125, lastbuyprice_withDiscountAndTax = 125
                where sellbilldetailid = 548209;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15919, '2024-12-18', 149.74358974359, 125, 125
                    , 125, 125, 125, 125
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 125, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-149.74358974359, sellCostBuyPrice =sellCostBuyPrice-125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-125, sellCostMeanBuyPrice = sellCostMeanBuyPrice-125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-125
                            , 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-18', 149.74358974359, 125, 125
                    , 125, 125, 125, 125
                    , 0, 0, 0, 0
                    , 0, 0, 0, 125, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-149.74358974359, sellCostBuyPrice =sellCostBuyPrice-125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-125, sellCostMeanBuyPrice = sellCostMeanBuyPrice-125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-125
                            , 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 = '8', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '15918';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15919', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '7', '8', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 34038;
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        
                where sellbilldetailid = 548210;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15285, '2024-12-18', 308.84615384615, 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-308.84615384615, 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-18', 308.84615384615, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-308.84615384615, 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 = '8', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '15284';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15285', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '7', '8', '2', '2024-12-14 14:00:04','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 548211;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10357, '2024-12-18', 233.97435897436, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-233.97435897436, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , 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-18', 233.97435897436, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-233.97435897436, sellCostBuyPrice =sellCostBuyPrice-250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-250
                            , 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 = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '10356';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10357', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-8', '-7', '2', '2024-12-14 14:00:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36490;
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 = 548213;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16483, '2024-12-18', 280.76923076923, 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-280.76923076923, 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-18', 280.76923076923, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-280.76923076923, 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 = '17', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16482';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16483', '1', '1', '0', '150066', 'تعديل فاتورة مبيعات', 'sellbillController.php', '16', '17', '2', '2024-12-14 14:00:04','0','0');
CALL clientInUse(3828,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '98392', userid = '2' WHERE clientid = '3828';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3828','106422.00','8030.00','1','تعديل فاتورة مبيعات','150066', '98392', '2024-12-14 14:00:04', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '8030', '0', null, '0', null, null,'', '0','1','1','8030','1','2024-12-14 14:00:04','0','0');
UPDATE client SET  inUse = 0 where clientid = 3828;
 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-18', 8030, 7025, 7025
                    , 7171, 7025, 7171, 6773.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,5980, 5601, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8030, sellCostBuyPrice =sellCostBuyPrice-7025
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-7025, sellCostMeanBuyPrice = sellCostMeanBuyPrice-7171
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-7025, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-7171
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-6773.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-5980
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-5601
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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 (3828, '2024-12-18', 8030, 7025, 7025
                    , 7171, 7025, 7171, 6773.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 5980, 5601, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8030, sellCostBuyPrice =sellCostBuyPrice-7025
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-7025, sellCostMeanBuyPrice = sellCostMeanBuyPrice-7171
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-7025, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-7171
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-6773.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-5980
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-5601
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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, 8030, 7025, 7025
                    , 7171, 7025, 7171, 6773.12, 5980, 5601)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-8030, netSellCostBuyPrice = netSellCostBuyPrice-7025
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-7025
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-7171
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-7025
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-7171
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-6773.12
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-5980
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-5601;

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


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

COMMIT;
BEGIN;
CALL clientInUse(3828,@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-14 14:00:04', '0675d734423c10', '3828', '98392.00', '106147', '525', '1', '8280', '7755', '0', '7755', '1', '2024-12-14 14:00:04', '', '2', '0', 'جريتو 52', '2', '1', '3', '90', 'جريتو 52', '24', '150066', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-14','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '106147', userid = '2' WHERE clientid = '3828';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3828','98392.00','7755','0','اضافة فاتورة مبيعات (معدله)','150067', '106147', '2024-12-18 16:34:35', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '7755', '0', null, '0', null, null,'', '0','1','1','8030','1','2024-12-14 14:00:04','0','0');
UPDATE client SET  inUse = 0 where clientid = 3828;
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', '150067', '14', '16257', '1', '270', '270', '0', '', '1', '2024-12-18 16:34:35', '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 = 548214;
 INSERT INTO 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-18', 252.88043478261, 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+252.88043478261, 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-18', 252.88043478261, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+252.88043478261, 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 = '13', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16256';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16257', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '14', '13', '2', '2024-12-18 16:34:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35975;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150067', '1', '16322', '1', '350', '350', '0', '', '1', '2024-12-18 16:34:35', '16322', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35975-1,','1','1','0','0','350','350','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 = 548215;
 INSERT INTO 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-18', 327.80797101449, 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+327.80797101449, 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-18', 327.80797101449, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+327.80797101449, 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 = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16321';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16322', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '31', '30', '2', '2024-12-18 16:34:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35938;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3318', '150067', '1', '16186', '2', '380', '760', '0', '', '1', '2024-12-18 16:34:35', '16186', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35938-2,','1','1','0','0','380','760','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 = 548216;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16186, '2024-12-18', 711.8115942029, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 620, 620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+711.8115942029, sellCostBuyPrice =sellCostBuyPrice+620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+620, sellCostMeanBuyPrice = sellCostMeanBuyPrice+620
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+620
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+620
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+620
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 711.8115942029, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0, 620, 620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+711.8115942029, sellCostBuyPrice =sellCostBuyPrice+620
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+620, sellCostMeanBuyPrice = sellCostMeanBuyPrice+620
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+620, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+620
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+620
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+620
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+620
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:34:35' WHERE storedetailid = '16185';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16186', '1', '2', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '20', '18', '2', '2024-12-18 16:34:35','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', '150067', '14', '16424', '1', '250', '250', '0', '', '1', '2024-12-18 16:34:35', '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 = 548217;
 INSERT INTO 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-18', 234.14855072464, 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+234.14855072464, 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-18', 234.14855072464, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+234.14855072464, 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 = '17', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16423';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16424', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '18', '17', '2', '2024-12-18 16:34:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35177;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3282', '150067', '1', '15867', '1', '500', '500', '0', '', '1', '2024-12-18 16:34:35', '15867', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35177-1,','1','1','0','0','500','500','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 = 247, lastbuyprice_withDiscountAndTax = 410
                where sellbilldetailid = 548218;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15867, '2024-12-18', 468.29710144928, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 410, 247, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+468.29710144928, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+247
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 468.29710144928, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 247, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+468.29710144928, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+247
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:34:35' WHERE storedetailid = '15866';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15867', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '12', '11', '2', '2024-12-18 16:34:35','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', '150067', '14', '16340', '1', '550', '550', '0', '', '1', '2024-12-18 16:34:35', '16340', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36008-1,','1','1','0','0','550','550','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 = 548219;
 INSERT INTO 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-18', 515.1268115942, 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+515.1268115942, 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-18', 515.1268115942, 425, 425
                    , 425, 425, 425, 425
                    , 0, 0, 0, 0
                    , 0, 0, 0, 425, 213, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+515.1268115942, 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 = '11', userid = '2', storedetaildate = '2024-12-18 16:34:35' WHERE storedetailid = '16339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16340', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '12', '11', '2', '2024-12-18 16:34:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35968;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150067', '5', '16205', '2', '810', '1620', '0', '', '1', '2024-12-18 16:34:36', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35968-2,','1','1','0','0','810','1620','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 = 548220;
 INSERT INTO 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-18', 1517.2826086957, 1460, 1460
                    , 1460, 1460, 1460, 1460
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 1460, 1460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1517.2826086957, sellCostBuyPrice =sellCostBuyPrice+1460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1460
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1460
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1460
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1460
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1517.2826086957, 1460, 1460
                    , 1460, 1460, 1460, 1460
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1460, 1460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1517.2826086957, sellCostBuyPrice =sellCostBuyPrice+1460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1460
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1460
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1460
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1460
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '2', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '55', '53', '2', '2024-12-18 16:34:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36029;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07210', '150067', '5', '16345', '1', '350', '350', '0', '', '1', '2024-12-18 16:34:36', '16345', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36029-1,','1','1','0','0','350','350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 295.00 , meanbuyprice = 293.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 293.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 293, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 548221;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16345, '2024-12-18', 327.80797101449, 295, 295
                    , 293, 295, 293, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 293, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+327.80797101449, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+293
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+293
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+293
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 327.80797101449, 295, 295
                    , 293, 295, 293, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 293, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+327.80797101449, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+293
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+293
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+293
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:34:36' WHERE storedetailid = '16344';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16345', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '9', '8', '2', '2024-12-18 16:34:36','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', '150067', '5', '16435', '1', '200', '200', '0', '', '1', '2024-12-18 16:34:36', '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 = 548222;
 INSERT INTO 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-18', 187.31884057971, 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+187.31884057971, 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-18', 187.31884057971, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+187.31884057971, 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 = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '16434';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16435', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '16', '15', '2', '2024-12-18 16:34:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36055;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150067', '5', '16294', '1', '210', '210', '0', '', '1', '2024-12-18 16:34:36', '16294', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36055-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 = 548223;
 INSERT INTO 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-18', 196.6847826087, 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+196.6847826087, 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-18', 196.6847826087, 155, 155
                    , 151, 155, 151, 153.12
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 153, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+196.6847826087, 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 = '82', userid = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '83', '82', '2', '2024-12-18 16:34:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35451;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07078', '150067', '5', '16061', '1', '285', '285', '0', '', '1', '2024-12-18 16:34:36', '16061', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35451-1,','1','1','0','0','285','285','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 = 548224;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16061, '2024-12-18', 266.92934782609, 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+266.92934782609, 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-18', 266.92934782609, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+266.92934782609, 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 = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '16060';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16061', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '6', '5', '2', '2024-12-18 16:34:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35803;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150067', '5', '16152', '1', '250', '250', '0', '', '1', '2024-12-18 16:34:36', '16152', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35803-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
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 548225;
 INSERT INTO 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-18', 234.14855072464, 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+234.14855072464, 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-18', 234.14855072464, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+234.14855072464, 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 = '27', userid = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '16151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16152', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '28', '27', '2', '2024-12-18 16:34:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34037;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3188', '150067', '1', '15356', '1', '210', '210', '0', '', '1', '2024-12-18 16:34:36', '15356', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34037-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
        
                where sellbilldetailid = 548226;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15356, '2024-12-18', 196.6847826087, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+196.6847826087, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , 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-18', 196.6847826087, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+196.6847826087, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , 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 = '1', userid = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '15355';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15356', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '2', '1', '2', '2024-12-18 16:34:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35892;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07066', '150067', '5', '16069', '1', '280', '280', '0', '', '1', '2024-12-18 16:34:36', '16069', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35892-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 = 548227;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16069, '2024-12-18', 262.24637681159, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+262.24637681159, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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-18', 262.24637681159, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+262.24637681159, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , 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 = '28', userid = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '16068';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16069', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '29', '28', '2', '2024-12-18 16:34:36','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', '150067', '5', '13802', '1', '450', '450', '0', '', '1', '2024-12-18 16:34:36', '13802', '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 = 380.00 , meanbuyprice = 532.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 532.00
        
                where sellbilldetailid = 548228;
 INSERT INTO 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-18', 421.46739130435, 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+421.46739130435, 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-18', 421.46739130435, 380, 380
                    , 532, 380, 532, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+421.46739130435, 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 = '0', userid = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '13801';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13802', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '1', '0', '2', '2024-12-18 16:34:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35382;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3276', '150067', '1', '15814', '1', '385', '385', '0', '', '1', '2024-12-18 16:34:36', '15814', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35382-1,','1','1','0','0','385','385','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 = 320, lastbuyprice_withDiscountAndTax = 320
                where sellbilldetailid = 548229;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15814, '2024-12-18', 360.58876811594, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360.58876811594, 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+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 360.58876811594, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360.58876811594, 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 = '5', userid = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '15813';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15814', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '6', '5', '2', '2024-12-18 16:34:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35374;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1528', '150067', '14', '16031', '1', '400', '400', '0', '', '1', '2024-12-18 16:34:36', '16031', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35374-1,','1','1','0','0','400','400','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 = 548230;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16031, '2024-12-18', 374.63768115942, 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+374.63768115942, 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-18', 374.63768115942, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+374.63768115942, 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 = '0', userid = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '16030';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16031', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '1', '0', '2', '2024-12-18 16:34:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35922;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07199', '150067', '5', '16299', '1', '200', '200', '0', '', '1', '2024-12-18 16:34:36', '16299', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35922-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 = 548231;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16299, '2024-12-18', 187.31884057971, 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+187.31884057971, 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-18', 187.31884057971, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+187.31884057971, 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 = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '16298';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16299', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '13', '12', '2', '2024-12-18 16:34:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35149;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3295', '150067', '1', '15919', '1', '160', '160', '0', '', '1', '2024-12-18 16:34:36', '15919', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35149-1,','1','1','0','0','160','160','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
        , lastbuyprice_withTax = 125, meanbuyprice_withTax = 125, lastbuyprice_withDiscountAndTax = 125
                where sellbilldetailid = 548232;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15919, '2024-12-18', 149.85507246377, 125, 125
                    , 125, 125, 125, 125
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 125, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+149.85507246377, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+125
                            , 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-18', 149.85507246377, 125, 125
                    , 125, 125, 125, 125
                    , 0, 0, 0, 0
                    , 0, 0, 0, 125, 125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+149.85507246377, sellCostBuyPrice =sellCostBuyPrice+125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+125
                            , 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 = '7', userid = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '15918';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15919', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '8', '7', '2', '2024-12-18 16:34:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34038;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3168', '150067', '1', '15285', '1', '330', '330', '0', '', '1', '2024-12-18 16:34:36', '15285', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34038-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
        
                where sellbilldetailid = 548233;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15285, '2024-12-18', 309.07608695652, 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+309.07608695652, 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-18', 309.07608695652, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+309.07608695652, 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 = '7', userid = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '15284';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15285', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '8', '7', '2', '2024-12-18 16:34:36','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','عرض 250', '150067', '18', '10357', '1', '250', '250', '0', '', '1', '2024-12-18 16:34:36', '10357', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','250','250','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 = 548234;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10357, '2024-12-18', 234.14855072464, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+234.14855072464, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , 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-18', 234.14855072464, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+234.14855072464, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , 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 = '-8', userid = '2', storedetaildate = '2024-12-18 16:34:36' WHERE storedetailid = '10356';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10357', '1', '1', '1', '150067', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '-7', '-8', '2', '2024-12-18 16:34:36','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', '150067', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 16:34:36', '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 quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-18', 7755, 6785, 6785
                    , 6931, 6785, 6931, 6533.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,5740, 5361, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7755, sellCostBuyPrice =sellCostBuyPrice+6785
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6785, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6931
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6785, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6931
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6533.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+5740
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5361
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (3828, '2024-12-18', 7755, 6785, 6785
                    , 6931, 6785, 6931, 6533.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,5740, 5361, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7755, sellCostBuyPrice =sellCostBuyPrice+6785
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6785, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6931
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6785, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6931
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6533.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+5740
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5361
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 7755, 6785, 6785
                    , 6931, 6785, 6931, 6533.12, 5740, 5361)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+7755, netSellCostBuyPrice = netSellCostBuyPrice+6785
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+6785
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+6931
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+6785
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+6931
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+6533.12
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+5740
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+5361;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150066 and newid=150067 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:04:37";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:34:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:34:37', '2', 'editprint', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150067');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:04:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:34:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:34:39', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:06:16";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:36:16", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:36:16', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:06:38";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:36:38", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:36:38', '75', 'add', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762bfecdd347
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3828,@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-18 14:28:28', '06762bfecdd347', '3828', '106147.00', '131180', '2', '1', '25035.00', '25033', '0', '25033', '1', '2024-12-18 16:36:38', '', '75', '0', 'جريتو 52', '2', '1', '3', '90', 'جريتو 52', '67' ,'0','','','','','-1','0','0','0','0','0','25033','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '131180', userid = '75' WHERE clientid = '3828';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3828','106147.00','25033','0','اضافة فاتورة مبيعات','150068', '131180', '2024-12-18 16:36:38', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '25033', '0', null, '0', null, null,'', '0','1','1','25033','1','2024-12-18 14:28:28','0','0');
UPDATE client SET  inUse = 0 where clientid = 3828;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35855;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07178', '150068', '5', '16234', '1', '550', '550', '0', '', '1', '2024-12-18 16:36:38', '16234', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35855-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 = 548236;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16234, '2024-12-18', 549.95606151388, 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+549.95606151388, 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-18', 549.95606151388, 455, 455
                    , 455, 455, 455, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+549.95606151388, 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 = '15', userid = '75', storedetaildate = '2024-12-18 16:36:38' WHERE storedetailid = '16233';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16234', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '75', '2024-12-18 16:36:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33288;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3117', '150068', '1', '15062', '1', '290', '290', '0', '', '1', '2024-12-18 16:36:38', '15062', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33288-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
        
                where sellbilldetailid = 548237;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15062, '2024-12-18', 289.97683243459, 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+289.97683243459, 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-18', 289.97683243459, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+289.97683243459, 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 = '13', userid = '75', storedetaildate = '2024-12-18 16:36:38' WHERE storedetailid = '15061';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15062', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-18 16:36:38','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', '150068', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-18 16:36:38', '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 = 548238;
 INSERT INTO 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-18', 199.98402236868, 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+199.98402236868, 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-18', 199.98402236868, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+199.98402236868, 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 = '38', userid = '75', storedetaildate = '2024-12-18 16:36:38' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '39', '38', '75', '2024-12-18 16:36:38','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', '150068', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-18 16:36:38', '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 = 305, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 548239;
 INSERT INTO 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-18', 399.96804473737, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 305, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+399.96804473737, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+305
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 399.96804473737, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 305, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+399.96804473737, sellCostBuyPrice =sellCostBuyPrice+335
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+335, sellCostMeanBuyPrice = sellCostMeanBuyPrice+335
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+335, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+335
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+305
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:36:38' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '38', '37', '75', '2024-12-18 16:36:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35575;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1489', '150068', '14', '15910', '1', '300', '300', '0', '', '1', '2024-12-18 16:36:38', '15910', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35575-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 = 548240;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15910, '2024-12-18', 299.97603355303, 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+299.97603355303, 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-18', 299.97603355303, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+299.97603355303, 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 = '8', userid = '75', storedetaildate = '2024-12-18 16:36:38' WHERE storedetailid = '15909';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15910', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-18 16:36:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35849;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1614', '150068', '14', '16258', '1', '260', '260', '0', '', '1', '2024-12-18 16:36:38', '16258', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35849-1,','1','1','0','0','260','260','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 = 548241;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16258, '2024-12-18', 259.97922907929, 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+259.97922907929, 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-18', 259.97922907929, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+259.97922907929, 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 = '8', userid = '75', storedetaildate = '2024-12-18 16:36:38' WHERE storedetailid = '16257';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16258', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-18 16:36:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36091;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07261', '150068', '5', '16367', '2', '580', '1160', '0', '', '1', '2024-12-18 16:36:38', '16367', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36091-2,','1','1','0','0','580','1160','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 496.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 496.00
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 499, lastbuyprice_withDiscountAndTax = 495
                where sellbilldetailid = 548242;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16367, '2024-12-18', 1159.9073297384, 990, 990
                    , 992, 990, 992, 995
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 990, 998, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1159.9073297384, sellCostBuyPrice =sellCostBuyPrice+990
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+990, sellCostMeanBuyPrice = sellCostMeanBuyPrice+992
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+990, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+992
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+995
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+990
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+998
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1159.9073297384, 990, 990
                    , 992, 990, 992, 995
                    , 0, 0, 0, 0
                    , 0, 0, 0, 990, 998, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1159.9073297384, sellCostBuyPrice =sellCostBuyPrice+990
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+990, sellCostMeanBuyPrice = sellCostMeanBuyPrice+992
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+990, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+992
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+995
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+990
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+998
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:36:38' WHERE storedetailid = '16366';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16367', '1', '2', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '11', '75', '2024-12-18 16:36:38','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 36343;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06603', '150068', '5', '15038', '3', '290', '870', '0', '', '1', '2024-12-18 16:36:38', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36343-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 = 548243;
 INSERT INTO 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-18', 869.93049730377, 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+869.93049730377, 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-18', 869.93049730377, 675, 675
                    , 678, 675, 678, 707.85
                    , 0, 0, 0, 0
                    , 0, 0, 0, 675, 681, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+869.93049730377, 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 = '61', userid = '75', storedetaildate = '2024-12-18 16:36:38' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '3', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '64', '61', '75', '2024-12-18 16:36:38','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', '150068', '5', '16321', '1', '310', '310', '0', '', '1', '2024-12-18 16:36:38', '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 = 548244;
 INSERT INTO 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-18', 309.97523467146, 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+309.97523467146, 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-18', 309.97523467146, 285, 285
                    , 285, 285, 285, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0, 285, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+309.97523467146, 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 = '17', userid = '75', storedetaildate = '2024-12-18 16:36:38' WHERE storedetailid = '16320';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16321', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36125;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07262', '150068', '5', '16384', '1', '260', '260', '0', '', '1', '2024-12-18 16:36:39', '16384', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36125-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 = 100, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 548245;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16384, '2024-12-18', 259.97922907929, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 200, 100, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+259.97922907929, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+100
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 259.97922907929, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 100, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+259.97922907929, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+200
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+200
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+100
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:36:39' WHERE storedetailid = '16383';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16384', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-18 16:36: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 ('330','R3239', '150068', '1', '15556', '1', '380', '380', '0', '', '1', '2024-12-18 16:36:39', '15556', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','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 = 1690, lastbuyprice_withDiscountAndTax = 330
                where sellbilldetailid = 548246;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15556, '2024-12-18', 379.9696425005, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 330, 1690, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+379.9696425005, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1690
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 379.9696425005, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 330, 1690, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+379.9696425005, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1690
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:36:39' WHERE storedetailid = '15555';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15556', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36427;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1570', '150068', '14', '16341', '2', '480', '960', '0', '', '1', '2024-12-18 16:36:39', '16341', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36427-2,','1','1','0','0','480','960','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 = 292, lastbuyprice_withDiscountAndTax = 350
                where sellbilldetailid = 548247;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16341, '2024-12-18', 959.92330736968, 700, 700
                    , 700, 700, 700, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 700, 584, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+959.92330736968, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+584
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 959.92330736968, 700, 700
                    , 700, 700, 700, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0, 700, 584, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+959.92330736968, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+584
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:36:39' WHERE storedetailid = '16340';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16341', '1', '2', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '13', '75', '2024-12-18 16:36:39','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', '150068', '5', '16434', '1', '200', '200', '0', '', '1', '2024-12-18 16:36:39', '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 = 548248;
 INSERT INTO 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-18', 199.98402236868, 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+199.98402236868, 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-18', 199.98402236868, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+199.98402236868, 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 = '8', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '16433';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16434', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 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', '150068', '5', '16415', '3', '200', '600', '0', '', '1', '2024-12-18 16:36:39', '16415', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36315-3,','1','1','0','0','200','600','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 = 548249;
 INSERT INTO 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-18', 599.95206710605, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+599.95206710605, 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+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-18', 599.95206710605, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+599.95206710605, 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 = '23', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '16414';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16415', '1', '3', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '23', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36155;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150068', '14', '15838', '1', '430', '430', '0', '', '1', '2024-12-18 16:36:39', '15838', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36155-1,','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 = 548250;
 INSERT INTO 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-18', 429.96564809267, 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+429.96564809267, 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-18', 429.96564809267, 360, 360
                    , 359, 360, 359, 356.92
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 359, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+429.96564809267, 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 = '11', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '15837';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15838', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35333;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1546', '150068', '14', '16000', '2', '670', '1340', '0', '', '1', '2024-12-18 16:36:39', '16000', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35333-2,','1','1','0','0','670','1340','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 = 548251;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16000, '2024-12-18', 1339.8929498702, 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+1339.8929498702, 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-18', 1339.8929498702, 1170, 1170
                    , 1170, 1170, 1170, 1170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1170, 1170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1339.8929498702, 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 = '3', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '15999';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16000', '1', '2', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '3', '75', '2024-12-18 16:36:39','0','0');
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', '150068', '5', '16004', '1', '230', '230', '0', '', '1', '2024-12-18 16:36:39', '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 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 = 548252;
 INSERT INTO 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-18', 229.98162572399, 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+229.98162572399, 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-18', 229.98162572399, 165, 165
                    , 164, 165, 164, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+229.98162572399, 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 = '-1', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '16003';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16004', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '75', '2024-12-18 16:36:39','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', '150068', '5', '16428', '2', '480', '960', '0', '', '1', '2024-12-18 16:36:39', '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 = 548253;
 INSERT INTO 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-18', 959.92330736968, 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+959.92330736968, 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-18', 959.92330736968, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+959.92330736968, 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 = '29', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '16427';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16428', '1', '2', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31', '29', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35719;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07159', '150068', '5', '16215', '1', '280', '280', '0', '', '1', '2024-12-18 16:36:39', '16215', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35719-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 = 548254;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16215, '2024-12-18', 279.97763131616, 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+279.97763131616, 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-18', 279.97763131616, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+279.97763131616, 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 = '4', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '16214';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16215', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 16:36:39','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', '150068', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-18 16:36:39', '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 = 548255;
 INSERT INTO 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-18', 479.96165368484, 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+479.96165368484, 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-18', 479.96165368484, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+479.96165368484, 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 = '65', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '66', '65', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35953;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150068', '14', '16312', '2', '530', '1060', '0', '', '1', '2024-12-18 16:36:39', '16312', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35953-2,','1','1','0','0','530','1060','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 = 548256;
 INSERT INTO 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-18', 1059.915318554, 880, 880
                    , 880, 880, 880, 880
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 880, 880, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1059.915318554, sellCostBuyPrice =sellCostBuyPrice+880
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+880, sellCostMeanBuyPrice = sellCostMeanBuyPrice+880
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+880, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+880
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+880
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+880
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+880
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1059.915318554, 880, 880
                    , 880, 880, 880, 880
                    , 0, 0, 0, 0
                    , 0, 0, 0, 880, 880, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1059.915318554, sellCostBuyPrice =sellCostBuyPrice+880
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+880, sellCostMeanBuyPrice = sellCostMeanBuyPrice+880
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+880, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+880
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+880
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+880
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+880
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:36:39' WHERE storedetailid = '16311';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16312', '1', '2', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '20', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35418;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150068', '14', '15853', '2', '280', '560', '0', '', '1', '2024-12-18 16:36:39', '15853', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35418-2,','1','1','0','0','280','560','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 = 548257;
 INSERT INTO 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-18', 559.95526263231, 440, 440
                    , 440, 440, 440, 441.58
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+559.95526263231, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+441.58
                            , 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+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-18', 559.95526263231, 440, 440
                    , 440, 440, 440, 441.58
                    , 0, 0, 0, 0
                    , 0, 0, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+559.95526263231, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+441.58
                            , 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 = '20', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '15852';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15853', '1', '2', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '20', '75', '2024-12-18 16:36:39','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', '150068', '5', '16343', '1', '490', '490', '0', '', '1', '2024-12-18 16:36:39', '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 = 548258;
 INSERT INTO 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-18', 489.96085480328, 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+489.96085480328, 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-18', 489.96085480328, 430, 430
                    , 428, 430, 428, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0, 430, 426, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+489.96085480328, 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 = '11', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '16342';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16343', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33157;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3097', '150068', '1', '14990', '1', '260', '260', '0', '', '1', '2024-12-18 16:36:39', '14990', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33157-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
        
                where sellbilldetailid = 548259;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14990, '2024-12-18', 259.97922907929, 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+259.97922907929, 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-18', 259.97922907929, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+259.97922907929, 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 = '1', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '14989';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14990', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-18 16:36:39','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', '150068', '5', '16416', '1', '380', '380', '0', '', '1', '2024-12-18 16:36:39', '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 = 548260;
 INSERT INTO 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-18', 379.9696425005, 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+379.9696425005, 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-18', 379.9696425005, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+379.9696425005, 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 = '9', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '16415';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16416', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35710;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07156', '150068', '5', '16209', '1', '310', '310', '0', '', '1', '2024-12-18 16:36:39', '16209', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35710-1,','1','1','0','0','310','310','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 196.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 196.00
        , lastbuyprice_withTax = 235, meanbuyprice_withTax = 232, lastbuyprice_withDiscountAndTax = 235
                where sellbilldetailid = 548261;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16209, '2024-12-18', 309.97523467146, 235, 235
                    , 196, 235, 196, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 235, 232, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+309.97523467146, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+196
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+196
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , 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-18', 309.97523467146, 235, 235
                    , 196, 235, 196, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 232, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+309.97523467146, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+196
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+196
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , 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 = '3', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '16208';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16209', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150068', '1', '16417', '2', '200', '400', '0', '', '1', '2024-12-18 16:36:39', '16417', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36320-2,','1','1','0','0','200','400','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 = 548262;
 INSERT INTO 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-18', 399.96804473737, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+399.96804473737, 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+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-18', 399.96804473737, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+399.96804473737, 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 = '19', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '16416';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16417', '1', '2', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '19', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36164;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3332', '150068', '1', '16399', '1', '160', '160', '0', '', '1', '2024-12-18 16:36:39', '16399', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36164-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 = 548263;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16399, '2024-12-18', 159.98721789495, 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+159.98721789495, 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-18', 159.98721789495, 110, 110
                    , 110, 110, 110, 110
                    , 0, 0, 0, 0
                    , 0, 0, 0, 110, 110, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+159.98721789495, 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 = '10', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '16398';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16399', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32749;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3054', '150068', '1', '14763', '1', '265', '265', '0', '', '1', '2024-12-18 16:36:39', '14763', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32749-1,','1','1','0','0','265','265','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 = 548264;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14763, '2024-12-18', 264.97882963851, 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+264.97882963851, 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-18', 264.97882963851, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+264.97882963851, 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 = '5', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '14762';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14763', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36106;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07265', '150068', '5', '16375', '1', '270', '270', '0', '', '1', '2024-12-18 16:36:39', '16375', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36106-1,','1','1','0','0','270','270','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 = 548265;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16375, '2024-12-18', 269.97843019772, 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+269.97843019772, 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-18', 269.97843019772, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 215, 215, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+269.97843019772, 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 = '10', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '16374';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16375', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36160;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07273', '150068', '5', '16395', '1', '600', '600', '0', '', '1', '2024-12-18 16:36:39', '16395', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36160-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 499.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 499.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 500, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 548266;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16395, '2024-12-18', 599.95206710605, 500, 500
                    , 499, 500, 499, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 500, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+599.95206710605, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+499
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+499
                            , 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-18', 599.95206710605, 500, 500
                    , 499, 500, 499, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 500, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+599.95206710605, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+499
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+499
                            , 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 = '42', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '16394';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16395', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '43', '42', '75', '2024-12-18 16:36:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36372;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1659', '150068', '14', '16439', '1', '600', '600', '0', '', '1', '2024-12-18 16:36:39', '16439', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36372-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 = 548267;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16439, '2024-12-18', 599.95206710605, 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+599.95206710605, 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-18', 599.95206710605, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 500, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+599.95206710605, 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 = '4', userid = '75', storedetaildate = '2024-12-18 16:36:39' WHERE storedetailid = '16438';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16439', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 16:36:39','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', '150068', '14', '16407', '1', '380', '380', '0', '', '1', '2024-12-18 16:36:40', '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 = 548268;
 INSERT INTO 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-18', 379.9696425005, 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+379.9696425005, 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-18', 379.9696425005, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+379.9696425005, 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 = '11', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16406';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16407', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-18 16:36:40','0','0');
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', '150068', '14', '16292', '1', '300', '300', '0', '', '1', '2024-12-18 16:36:40', '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 = 548269;
 INSERT INTO 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-18', 299.97603355303, 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+299.97603355303, 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-18', 299.97603355303, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+299.97603355303, 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 = '29', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16291';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16292', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '30', '29', '75', '2024-12-18 16:36:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31563;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('345','06217', '150068', '5', '14146', '1', '340', '340', '0', '', '1', '2024-12-18 16:36:40', '14146', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31563-1,','1','1','0','0','340','340','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 345.00 , meanbuyprice = 838.00, lastbuyprice_withDiscount = 345.00, meanbuyprice_withDiscount = 838.00
        
                where sellbilldetailid = 548270;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14146, '2024-12-18', 339.97283802676, 345, 345
                    , 838, 345, 838, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+339.97283802676, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+838
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+838
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 339.97283802676, 345, 345
                    , 838, 345, 838, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+339.97283802676, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+838
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+838
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:36:40' WHERE storedetailid = '14145';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14146', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 16:36:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36432;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07306', '150068', '5', '16459', '1', '400', '400', '0', '', '1', '2024-12-18 16:36:40', '16459', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36432-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 = 548271;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16459, '2024-12-18', 399.96804473737, 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+399.96804473737, 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-18', 399.96804473737, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+399.96804473737, 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 = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16458';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16459', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-18 16:36:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36016;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07164', '150068', '5', '16350', '1', '620', '620', '0', '', '1', '2024-12-18 16:36:40', '16350', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36016-1,','1','1','0','0','620','620','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 = 575, lastbuyprice_withDiscountAndTax = 575
                where sellbilldetailid = 548272;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16350, '2024-12-18', 619.95046934292, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 575, 575, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+619.95046934292, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+575
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 619.95046934292, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0, 575, 575, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+619.95046934292, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+575
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:36:40' WHERE storedetailid = '16349';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16350', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-18 16:36:40','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', '150068', '5', '16282', '1', '600', '600', '0', '', '1', '2024-12-18 16:36:40', '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 = 548273;
 INSERT INTO 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-18', 599.95206710605, 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+599.95206710605, 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-18', 599.95206710605, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 437, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+599.95206710605, 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 = '13', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16281';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16282', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-18 16:36:40','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', '150068', '1', '16446', '1', '160', '160', '0', '', '1', '2024-12-18 16:36:40', '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 = 548274;
 INSERT INTO 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-18', 159.98721789495, 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+159.98721789495, 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-18', 159.98721789495, 110, 110
                    , 110, 110, 110, 110
                    , 0, 0, 0, 0
                    , 0, 0, 0, 110, 110, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+159.98721789495, 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 = '11', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16445';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16446', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-18 16:36:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150068', '5', '16389', '2', '300', '600', '0', '', '1', '2024-12-18 16:36:40', '16389', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36151-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 = 548275;
 INSERT INTO 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-18', 599.95206710605, 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+599.95206710605, 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-18', 599.95206710605, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+599.95206710605, 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 = '12', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16388';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16389', '1', '2', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '12', '75', '2024-12-18 16:36:40','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', '150068', '14', '16430', '2', '500', '1000', '0', '', '1', '2024-12-18 16:36:40', '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 = 548276;
 INSERT INTO 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-18', 999.92011184342, 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+999.92011184342, 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-18', 999.92011184342, 800, 800
                    , 800, 800, 800, 800
                    , 0, 0, 0, 0
                    , 0, 0, 0, 800, 800, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+999.92011184342, 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 = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16429';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16430', '1', '2', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '16', '75', '2024-12-18 16:36:40','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', '150068', '5', '16379', '1', '220', '220', '0', '', '1', '2024-12-18 16:36:40', '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 = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 160, lastbuyprice_withDiscountAndTax = 160
                where sellbilldetailid = 548277;
 INSERT INTO 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-18', 219.98242460555, 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+219.98242460555, 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-18', 219.98242460555, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 160, 160, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+219.98242460555, 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 = '27', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16378';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16379', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28', '27', '75', '2024-12-18 16:36:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34702;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3174', '150068', '1', '15319', '1', '330', '330', '0', '', '1', '2024-12-18 16:36:40', '15319', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34702-1,','1','1','0','0','330','330','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 = 178, lastbuyprice_withDiscountAndTax = 285
                where sellbilldetailid = 548278;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15319, '2024-12-18', 329.97363690833, 285, 285
                    , 285, 285, 285, 283.75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 285, 178, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+329.97363690833, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+285
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+285
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+283.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+178
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 329.97363690833, 285, 285
                    , 285, 285, 285, 283.75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 285, 178, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+329.97363690833, sellCostBuyPrice =sellCostBuyPrice+285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+285, sellCostMeanBuyPrice = sellCostMeanBuyPrice+285
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+285
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+283.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+285
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+178
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:36:40' WHERE storedetailid = '15318';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15319', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-27', '-28', '75', '2024-12-18 16:36:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36370;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3338', '150068', '1', '16437', '1', '340', '340', '0', '', '1', '2024-12-18 16:36:40', '16437', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36370-1,','1','1','0','0','340','340','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 = 548279;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16437, '2024-12-18', 339.97283802676, 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+339.97283802676, 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-18', 339.97283802676, 285, 285
                    , 285, 285, 285, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0, 285, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+339.97283802676, 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 = '25', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16436';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16437', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '75', '2024-12-18 16:36:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35851;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1609', '150068', '14', '16260', '1', '400', '400', '0', '', '1', '2024-12-18 16:36:40', '16260', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35851-1,','1','1','0','0','400','400','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 = 548280;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16260, '2024-12-18', 399.96804473737, 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+399.96804473737, 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-18', 399.96804473737, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+399.96804473737, 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 = '1', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16259';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16260', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-18 16:36:40','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', '150068', '1', '16410', '1', '470', '470', '0', '', '1', '2024-12-18 16:36:40', '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 = 548281;
 INSERT INTO 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-18', 469.96245256641, 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+469.96245256641, 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-18', 469.96245256641, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+469.96245256641, 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 = '9', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16409';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16410', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-18 16:36:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36202;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07138', '150068', '5', '16170', '1', '300', '300', '0', '', '1', '2024-12-18 16:36:40', '16170', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36202-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 = 548282;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16170, '2024-12-18', 299.97603355303, 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+299.97603355303, 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-18', 299.97603355303, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+299.97603355303, 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 = '11', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16169';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16170', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-18 16:36:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36084;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('600','H1643', '150068', '14', '16364', '1', '730', '730', '0', '', '1', '2024-12-18 16:36:40', '16364', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36084-1,','1','1','0','0','730','730','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 600.00 , meanbuyprice = 600.00, lastbuyprice_withDiscount = 600.00, meanbuyprice_withDiscount = 600.00
        , lastbuyprice_withTax = 600, meanbuyprice_withTax = 600, lastbuyprice_withDiscountAndTax = 600
                where sellbilldetailid = 548283;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16364, '2024-12-18', 729.9416816457, 600, 600
                    , 600, 600, 600, 600
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 600, 600, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+729.9416816457, 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
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 729.9416816457, 600, 600
                    , 600, 600, 600, 600
                    , 0, 0, 0, 0
                    , 0, 0, 0, 600, 600, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+729.9416816457, 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;
UPDATE storedetail SET  productquantity = '19', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16363';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16364', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '75', '2024-12-18 16:36:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36448;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1646', '150068', '14', '16460', '1', '570', '570', '0', '', '1', '2024-12-18 16:36:40', '16460', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36448-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 = 548284;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16460, '2024-12-18', 569.95446375075, 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+569.95446375075, 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-18', 569.95446375075, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+569.95446375075, 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 = '7', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16459';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16460', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-18 16:36:40','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', '150068', '5', '16374', '1', '300', '300', '0', '', '1', '2024-12-18 16:36:40', '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 = 548285;
 INSERT INTO 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-18', 299.97603355303, 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+299.97603355303, 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-18', 299.97603355303, 225, 225
                    , 231, 225, 231, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 225, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+299.97603355303, 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 = '17', userid = '75', storedetaildate = '2024-12-18 16:36: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', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '75', '2024-12-18 16:36:40','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', '150068', '14', '15405', '1', '820', '820', '0', '', '1', '2024-12-18 16:36:40', '15405', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35676-1,','1','1','0','0','820','820','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 = 548286;
 INSERT INTO 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-18', 819.9344917116, 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+819.9344917116, 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-18', 819.9344917116, 735, 735
                    , 704, 735, 704, 690.83
                    , 0, 0, 0, 0
                    , 0, 0, 0, 735, 599, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+819.9344917116, 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 = '3', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '15404';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15405', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-18 16:36:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36490;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07292', '150068', '5', '16483', '1', '300', '300', '0', '', '1', '2024-12-18 16:36:40', '16483', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36490-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 = 548287;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16483, '2024-12-18', 299.97603355303, 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+299.97603355303, 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-18', 299.97603355303, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+299.97603355303, 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 = '16', userid = '75', storedetaildate = '2024-12-18 16:36:40' WHERE storedetailid = '16482';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16483', '1', '1', '1', '150068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '75', '2024-12-18 16:36: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', '150068', '9', '2015', '2', '20', '40', '0', '', '1', '2024-12-18 16:36:40', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','40','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 90 where clientid = 3828;
 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-18', 25033, 20690, 20690
                    , 21119, 20690, 21119, 20703.43
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,19645, 20412, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+25033, sellCostBuyPrice =sellCostBuyPrice+20690
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+20690, sellCostMeanBuyPrice = sellCostMeanBuyPrice+21119
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+20690, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+21119
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+20703.43
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+19645
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+20412
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (3828, '2024-12-18', 25033, 20690, 20690
                    , 21119, 20690, 21119, 20703.43
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,19645, 20412, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+25033, sellCostBuyPrice =sellCostBuyPrice+20690
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+20690, sellCostMeanBuyPrice = sellCostMeanBuyPrice+21119
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+20690, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+21119
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+20703.43
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+19645
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+20412
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 25033, 20690, 20690
                    , 21119, 20690, 21119, 20703.43, 19645, 20412)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+25033, netSellCostBuyPrice = netSellCostBuyPrice+20690
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+20690
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+21119
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+20690
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+21119
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+20703.43
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+19645
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+20412;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762bfecdd347 and sellbillId = 150068 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:06:41";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:36:41", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:36:41', '75', 'editprint', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150068');
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 ('7318','','5','455','530', '530','530', '2024-12-18', '0', '77', '1', '07318', '0', '0', '0', '0', '0', '455','455','455','455','455','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','455','455','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16488, 1,'2024-12-18 16:37:55',77)
                ON DUPLICATE KEY UPDATE productid = 16488, edited = 1, sysdate = '2024-12-18 16:37: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', '16488', '1', '2024-12-18', '77', '0','1648801','530','530','530','455','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16488', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16488', '1', '0', '0', '16488', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:08:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:38:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:38:09', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762dd7f73b68
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7978,@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-18 16:34:39', '06762dd7f73b68', '7978', '1020.00', '1828', '0', '1', '808.00', '808', '0', '808', '1', '2024-12-18 16:38:09', '', '104', '0', 'يمني يحيي b14', '1', '1', '3', '93', 'يمني يحيي b14', '3' ,'0','','','','','-1','0','0','0','0','0','808','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1828', userid = '104' WHERE clientid = '7978';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7978','1020.00','808','0','اضافة فاتورة مبيعات','150069', '1828', '2024-12-18 16:38:09', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '808', '0', null, '0', null, null,'', '0','1','1','808','1','2024-12-18 16:34:39','0','0');
UPDATE client SET  inUse = 0 where clientid = 7978;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150069', '5', '16279', '2', '400', '800', '0', '', '1', '2024-12-18 16:38:09', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36150-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 = 305, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 548289;
 INSERT INTO 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-18', 800, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 670, 610, 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+610
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 800, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0, 670, 610, 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+610
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:38:09' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '2', '1', '150069', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37', '35', '104', '2024-12-18 16:38:09','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', '150069', '17', '10291', '1', '8', '8', '0', '', '1', '2024-12-18 16:38:09', '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 = 93 where clientid = 7978;
 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-18', 808, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,670, 610, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+808, sellCostBuyPrice =sellCostBuyPrice+670
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+670, sellCostMeanBuyPrice = sellCostMeanBuyPrice+670
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+670, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+670
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+670
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+670
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+610
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (7978, '2024-12-18', 808, 670, 670
                    , 670, 670, 670, 670
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,670, 610, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+808, sellCostBuyPrice =sellCostBuyPrice+670
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+670, sellCostMeanBuyPrice = sellCostMeanBuyPrice+670
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+670, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+670
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+670
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+670
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+610
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 808, 670, 670
                    , 670, 670, 670, 670, 670, 610)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+808, netSellCostBuyPrice = netSellCostBuyPrice+670
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+670
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+670
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+670
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+670
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+670
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+670
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+610;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762dd7f73b68 and sellbillId = 150069 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:08:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:38:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:38:09', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE productunit SET unitid = '1', productid = '16379', productnumber = '1.00', productunitdate = '2024-12-10', userid = '77', conditions = '0',proUnitParcode='1637901',proUnitSellAllPrice='220',proUnitSellHalfPrice='220',proUnitSellUnitPrice ='220',proUnitBuyPrice='160',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16379';
UPDATE product SET productName = '7271', productDescription = '', productCatId = '5', productBuyPrice = '165', productSellAllPrice = '220', productSellUnitPrice = '220', productSellHalfPrice = '220', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07271',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 = '16379';
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 ('7320','','5','240','300', '300','300', '2024-12-18', '0', '77', '1', '07320', '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 (16489, 1,'2024-12-18 16:38:40',77)
                ON DUPLICATE KEY UPDATE productid = 16489, edited = 1, sysdate = '2024-12-18 16:38: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', '16489', '1', '2024-12-18', '77', '0','1648901','300','300','300','240','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16489', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16489', '1', '0', '0', '16489', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:08:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:38:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:38:50', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762de522a4fd
-- ----------------------------------------------------------------------------------------------------

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-18 16:38:10', '06762de522a4fd', '1', '0.00', '0', '0', '1', '360.00', '360', '360', '0', '1', '2024-12-18 16:38:50', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150070', '0', '2024-12-18 16:38:50', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '360', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:38:10','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', '150070', '5', '15654', '1', '360', '360', '0', '', '1', '2024-12-18 16:38:50', '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 = 548291;
 INSERT INTO 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-18', 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-18', 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 = '14', userid = '104', storedetaildate = '2024-12-18 16:38:50' WHERE storedetailid = '15653';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15654', '1', '1', '1', '150070', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-18 16:38:50','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '31335',  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 ('30975','360', '0', '1', 'اضافة فاتورة مبيعات', '150070', '31335', '2024-12-18 16:38:50', '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-18', 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-18', 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 06762de522a4fd and sellbillId = 150070 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:08:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:38:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:38:50', '104', 'addsellBill', '192.168.1.13', '', '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 ('7323','','5','240','300', '300','300', '2024-12-18', '0', '77', '1', '07323', '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 (16490, 1,'2024-12-18 16:38:59',77)
                ON DUPLICATE KEY UPDATE productid = 16490, edited = 1, sysdate = '2024-12-18 16:38: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', '16490', '1', '2024-12-18', '77', '0','1649001','300','300','300','240','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16490', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16490', '1', '0', '0', '16490', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:09:06";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:39:06", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:39:06', '77', 'add', '192.168.1.21', '', '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 ('06762dde0c3c1f', '2024-12-18 16:36:16', '78', '309450.00', '333150', '0', '0', '23700',  '23700', '0', '23700', '1', '2024-12-18 16:39:06', '', '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 ('07318', '14143', '5', '16488', '15', '455', '6825', '0', '', '2024-12-18 16:39:06', '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-18 16:36:16', 1, 16488, 0, 0
                    , 455, 15, 0, 0, 77, '2024-12-18 16:39:06')
                ON DUPLICATE KEY UPDATE buyprice = 455,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:39:06' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16488', '455', '15', '0', 'buyBillController.php', '32735', '', '0', '0');
UPDATE product SET  productBuyPrice = "455" WHERE productId = 16488 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32735 ;
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='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='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 = 32735;
UPDATE productunit SET proUnitBuyPrice  = 455 * productnumber WHERE productid = 16488;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16487';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16488', '1', '15', '0', '14143', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 16:36:16','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 ('07271', '14143', '5', '16379', '15', '165', '2475', '0', '', '2024-12-18 16:39:06', '16379','','','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-18 16:36:16', 1, 16379, 0, 0
                    , 165, 15, 0, 0, 77, '2024-12-18 16:39:06')
                ON DUPLICATE KEY UPDATE buyprice = 165,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:39:06' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16379', '165', '15', '0', 'buyBillController.php', '32736', '', '0', '0');
UPDATE product SET  productBuyPrice = "165" WHERE productId = 16379 ;
UPDATE buybilldetail SET  quantitybefore = 27 WHERE buybilldetailid = 32736 ;
UPDATE product SET productName = '7271', 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 = '07271',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '165',lastbuyprice_withDiscount = '165',meanbuyprice = '163',meanbuyprice_withDiscount = '163' , 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 = '16379';
UPDATE buybilldetail SET  lastbuyprice = 165 , meanbuyprice = 163, lastbuyprice_withDiscount = 165, meanbuyprice_withDiscount = 163
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 162, lastbuyprice_withDiscountAndTax = 165
                where buybilldetailid = 32736;
UPDATE productunit SET proUnitBuyPrice  = 165 * productnumber WHERE productid = 16379;
UPDATE storedetail SET  productquantity = '42', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16378';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16379', '1', '15', '0', '14143', 'اضافة فاتورة مشتريات', 'buyBillController.php', '27', '42', '77', '2024-12-18 16:36:16','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 ('07100', '14143', '5', '16114', '15', '240', '3600', '0', '', '2024-12-18 16:39:06', '16114','','','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-18 16:36:16', 1, 16114, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-18 16:39:06')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:39:06' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16114', '240', '15', '0', 'buyBillController.php', '32737', '', '0', '0');
UPDATE product SET  productBuyPrice = "240" WHERE productId = 16114 ;
UPDATE buybilldetail SET  quantitybefore = 17 WHERE buybilldetailid = 32737 ;
UPDATE product SET productName = '7100', productDescription = '', productCatId = '5', productBuyPrice = '240.00', productSellAllPrice = '420.00', productSellUnitPrice = '420.00', productSellHalfPrice = '420.00', productDate = '2024-11-26', conditions = '0', userId = '77', limitamount = '1', parcode = '07100',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 = '16114';
UPDATE buybilldetail SET  lastbuyprice = 240 , meanbuyprice = 240, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 240
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32737;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16114;
UPDATE storedetail SET  productquantity = '32', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16113';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16114', '1', '15', '0', '14143', 'اضافة فاتورة مشتريات', 'buyBillController.php', '17', '32', '77', '2024-12-18 16:36:16','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 ('07248', '14143', '5', '16332', '15', '240', '3600', '0', '', '2024-12-18 16:39:06', '16332','','','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-18 16:36:16', 1, 16332, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-18 16:39:06')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:39:06' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16332', '240', '15', '0', 'buyBillController.php', '32738', '', '0', '0');
UPDATE product SET  productBuyPrice = "240" WHERE productId = 16332 ;
UPDATE buybilldetail SET  quantitybefore = 25 WHERE buybilldetailid = 32738 ;
UPDATE product SET productName = '7248', 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 = '07248',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '240',lastbuyprice_withDiscount = '240',meanbuyprice = '239',meanbuyprice_withDiscount = '239' , productbuypricereal = '235.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='240',meanbuyprice_withTax='239',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 = '16332';
UPDATE buybilldetail SET  lastbuyprice = 240 , meanbuyprice = 239, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 239
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 239, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32738;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16332;
UPDATE storedetail SET  productquantity = '40', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16331';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16332', '1', '15', '0', '14143', 'اضافة فاتورة مشتريات', 'buyBillController.php', '25', '40', '77', '2024-12-18 16:36:16','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 ('07320', '14143', '5', '16489', '15', '240', '3600', '0', '', '2024-12-18 16:39:06', '16489','','','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-18 16:36:16', 1, 16489, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-18 16:39:06')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:39:06' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16489', '240', '15', '0', 'buyBillController.php', '32739', '', '0', '0');
UPDATE product SET  productBuyPrice = "240" WHERE productId = 16489 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32739 ;
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',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 = '16489';
UPDATE buybilldetail SET  lastbuyprice = 240 , meanbuyprice = 240, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 240
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32739;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16489;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16488';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16489', '1', '15', '0', '14143', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 16:36:16','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', '14143', '5', '16490', '15', '240', '3600', '0', '', '2024-12-18 16:39:06', '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-18 16:36:16', 1, 16490, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-18 16:39:06')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:39:06' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16490', '240', '15', '0', 'buyBillController.php', '32740', '', '0', '0');
UPDATE product SET  productBuyPrice = "240" WHERE productId = 16490 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32740 ;
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='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 = '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 = 32740;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16490;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16489';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16490', '1', '15', '0', '14143', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 16:36:16','0','0');
UPDATE supplier SET  suppliercurrentDebt = '333150',suppliercurrentDebtInCurrency= '333150' , userid = '77', supplierdate = '2024-12-18 16:39:06'   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', '309450.00', '23700', '0', 'اضافة فاتورة مشتريات', '14143', '333150', '2024-12-18 16:36:16', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','23700','1','309450','23700','333150','0');
update buybill set dailyentryid='0,' where buybillid=14143;
COMMIT;
UPDATE product SET overAllAveragePrice = 240 WHERE productId = 16114;UPDATE product SET overAllAveragePrice = 238.33 WHERE productId = 16332;UPDATE product SET overAllAveragePrice = 161.67 WHERE productId = 16379;UPDATE product SET overAllAveragePrice = 455 WHERE productId = 16488;UPDATE product SET overAllAveragePrice = 240 WHERE productId = 16489;UPDATE product SET overAllAveragePrice = 240 WHERE productId = 16490;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:09:07";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:39:07", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:39:07', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14143');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:10:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:40:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 16:40:41', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:10:58";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:40:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-18 16:40:58', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:10:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:40:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 16:40:59', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247387
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7978,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '1818' , clientdate = '2024-12-18 16:40:59', userid = '104' WHERE clientid = '7978';
UPDATE client SET  inUse = 0 where clientid = 7978;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7978','1828.00','10','1','ايصال تحصيل (( قبض من عميل ))','247387', '1818', '2024-12-18 16:40:41', '104', 'clientPayedDeptController.php', '   ', '10', '0', null, '0', null, null,'', '-1','1','1','10','1','','3520','0');
UPDATE save SET  savecurrentvalue = '31345',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('31335.00','10', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '247387', '31345', '2024-12-18 16:40:59', '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 ('يمني يحيي b14', 'يمني يحيي b14', 'يمني يحيي b14', 'يمني يحيي b14', '58', '0', '1818.00', '0', '', '0', '0', '', '0', '3', '1', '', '104', '0', '2024-12-18 16:40:59');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '10', '10', '2024-12-18', '104', '0', '0', '2024-12-18 16:40:59','اضافة ايصال سداد للعميل يمني يحيي b14','1','0','-1','0','247387','clientPayedDeptController.php?do=show&id=247387');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122167', '-1', '10', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '10', 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 ('122167', '12556', '10', '','0');
UPDATE accountstree SET name = 'يمني يحيي b14', customName = 'يمني يحيي b14', customNameEn = 'يمني يحيي b14', nameEn = 'يمني يحيي b14', parent = '58', accountNature = '0', theValue = '1808', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '104', del = '0', sysdate = '2024-12-18 16:40:59' WHERE id = '12556';
UPDATE clientdebtchange SET clientid = '7978', clientdebtchangebefore = '1828.000', clientdebtchangeamount = '10.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247387', clientdebtchangeafter = '1818.000', clientdebtchangedate = '2024-12-18 16:40:41', userid = '104', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '10.00',discount='', reciptid='0', dailyentryid = '122167',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='10',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247387';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:10:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:40:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 16:40:59', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:11:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:41:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 16:41:01', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:11:10";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:41:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-18 16:41:10', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:11:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:41:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:41:50', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:12:01";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:42:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-18 16:42:01', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:12:31";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:42:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:42:31', '2', '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-18 13:12:43";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:42:43", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:42:43', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762df2ea6fb2
-- ----------------------------------------------------------------------------------------------------

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-18 16:41:50', '06762df2ea6fb2', '1', '0.00', '0', '0', '1', '960', '960', '-960', '0', '1', '2024-12-18 16:42:43', '', '104', '0', 'نقدي','1', '0', '5', '74', 'نقدي', '2', '0', '', '','','','-1','0','0','0','','0','-960','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','اضافة فاتورة مردوات مبيعات','16819', '0', '2024-12-18 16:42:43', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '960', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:41:50','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 ('420.00', '07037', '16819', '5', '15995', '2', '480', '960', '0', '', '1', '0', '15995', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','480','960','0','','0');
UPDATE returnsellbilldetail 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 returnsellbilldetailid = 22001;
 INSERT INTO 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 960, 840, 840, 840
                    , 840, 840, 840, 0, 2, 0, 0, 840, 840)
                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+960, returnSellCostBuyPrice = returnSellCostBuyPrice+840, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+840
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+840, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+840
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+840
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+840
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+840
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+840
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+2;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 960, 840, 840, 840
                    , 840, 840, 840, 0, 0, 840, 840)
                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+960, returnSellCostBuyPrice = returnSellCostBuyPrice+840, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+840
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+840, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+840
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+840
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+840
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+840
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+840;
UPDATE storedetail SET  productquantity = '67', userid = '104', storedetaildate = '2024-12-18 16:42:43' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '2', '0', '16819', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '65', '67', '104', '2024-12-18 16:42:43','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '30385',  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 ('31345','-960', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16819', '30385', '2024-12-18 16:42:43', '104',  'returnsellbillController.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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 960, 840, 840, 840
                    , 840, 840, 840 ,0, 0, 840, 840)
                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+960, returnSellCostBuyPrice = returnSellCostBuyPrice+840, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+840
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+840, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+840
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+840
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+840
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+840
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+840;
 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 960, 840, 840, 840
                    , 840, 840, 840 ,0, 0, 840, 840)
                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+960, returnSellCostBuyPrice = returnSellCostBuyPrice+840, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+840
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+840, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+840
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+840
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+840
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+840
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+840;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -960, -840, -840
                    , -840, -840, -840, -840, -840, -840)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-960, 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 06762df2ea6fb2 and sellbillId = 16819 and returnsellbillId = 16819
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:12:44";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:42:44", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:42:44', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:13:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:43:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:43:18', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:14:10";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:44:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 16:44:10', '77', 'oneSupplier', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:14:20";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:44:20", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 16:44:20', '77', 'oneSupplier', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:15:21";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:45:21", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:45: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 06762dca034d1f
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4642,@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-18 16:30:56', '06762dca034d1f', '4642', '0.00', '303', '0', '1', '303.00', '303', '0', '303', '1', '2024-12-18 16:45:21', '', '75', '0', 'جونير سامح f5', '2', '1', '3', '86', 'جونير سامح f5', '3' ,'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-18','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 = '4642';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4642','0.00','303','0','اضافة فاتورة مبيعات','150071', '303', '2024-12-18 16:45:21', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '303', '0', null, '0', null, null,'', '0','1','1','303','1','2024-12-18 16:30:56','0','0');
UPDATE client SET  inUse = 0 where clientid = 4642;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35874;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07104', '150071', '5', '16116', '1', '280', '280', '0', '', '1', '2024-12-18 16:45:21', '16116', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35874-1,','1','1','0','0','280','280','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 236.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 236.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 231, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 548292;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16116, '2024-12-18', 280, 240, 240
                    , 236, 240, 236, 230.77
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 231, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+236
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+236
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230.77
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+231
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 280, 240, 240
                    , 236, 240, 236, 230.77
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 231, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+236
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+236
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230.77
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+231
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:45:22' WHERE storedetailid = '16115';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16116', '1', '1', '1', '150071', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '75', '2024-12-18 16:45:22','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', '150071', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 16:45: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', '150071', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-18 16:45:22', '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 = 86 where clientid = 4642;
 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-18', 303, 240, 240
                    , 236, 240, 236, 230.77
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 231, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+303, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+236
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+236
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230.77
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+231
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (4642, '2024-12-18', 303, 240, 240
                    , 236, 240, 236, 230.77
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 231, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+303, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+236
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+236
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230.77
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+231
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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
                    , 236, 240, 236, 230.77, 240, 231)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+303, netSellCostBuyPrice = netSellCostBuyPrice+240
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+240
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+236
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+240
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+236
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+230.77
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+240
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+231;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762dca034d1f and sellbillId = 150071 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:15:22";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:45:22", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:45: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-18 13:15:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:45:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:45:33', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762df86b1e70
-- ----------------------------------------------------------------------------------------------------

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-18 16:43:18', '06762df86b1e70', '1', '0.00', '0', '0', '1', '1855.00', '1855', '1855', '0', '1', '2024-12-18 16:45:33', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '6' ,'0','','','','','-1','0','0','0','0','0','1855','0','','0','0','1855','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150072', '0', '2024-12-18 16:45:33', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1855', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:43:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150072', '5', '16195', '2', '220', '440', '0', '', '1', '2024-12-18 16:45:33', '16195', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35691-2,','1','1','0','0','220','440','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 = 548295;
 INSERT INTO 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-18', 440, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, 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+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-18', 440, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, 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 = '8', userid = '104', storedetaildate = '2024-12-18 16:45:33' WHERE storedetailid = '16194';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16195', '1', '2', '1', '150072', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '8', '104', '2024-12-18 16:45: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 ('150','R3156', '150072', '1', '15206', '1', '220', '220', '0', '', '1', '2024-12-18 16:45:33', '15206', '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 = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        
                where sellbilldetailid = 548296;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15206, '2024-12-18', 220, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , 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-18', 220, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , 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-18 16:45:33' WHERE storedetailid = '15205';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15206', '1', '1', '1', '150072', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-18 16:45:33','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', '150072', '5', '15654', '1', '360', '360', '0', '', '1', '2024-12-18 16:45:33', '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 = 548297;
 INSERT INTO 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-18', 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-18', 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 = '13', userid = '104', storedetaildate = '2024-12-18 16:45:33' WHERE storedetailid = '15653';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15654', '1', '1', '1', '150072', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '104', '2024-12-18 16:45:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35565;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1444', '150072', '14', '15782', '1', '500', '500', '0', '', '1', '2024-12-18 16:45:33', '15782', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35565-1,','1','1','0','0','500','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 408.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 408.00
        , lastbuyprice_withTax = 410, meanbuyprice_withTax = 406, lastbuyprice_withDiscountAndTax = 410
                where sellbilldetailid = 548298;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15782, '2024-12-18', 500, 410, 410
                    , 408, 410, 408, 403.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 410, 406, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+408
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+408
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+403.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+406
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 500, 410, 410
                    , 408, 410, 408, 403.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 406, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+408
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+408
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+403.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+406
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:45:33' WHERE storedetailid = '15781';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15782', '1', '1', '1', '150072', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-18 16:45: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 ('495','05400', '150072', '5', '11766', '1', '335', '335', '0', '', '1', '2024-12-18 16:45:33', '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 = 548299;
 INSERT INTO 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-18', 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-18', 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 = '3', userid = '104', storedetaildate = '2024-12-18 16:45:33' WHERE storedetailid = '11765';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11766', '1', '1', '1', '150072', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-18 16:45:33','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '32240',  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 ('30385','1855', '0', '1', 'اضافة فاتورة مبيعات', '150072', '32240', '2024-12-18 16:45:33', '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-18', 1855, 1680, 1680
                    , 1739, 1680, 1736, 1670
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1035, 1092, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1855, sellCostBuyPrice =sellCostBuyPrice+1680
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1680, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1739
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1680, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1736
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1670
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1035
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1092
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1855, 1680, 1680
                    , 1739, 1680, 1736, 1670
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1035, 1092, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1855, sellCostBuyPrice =sellCostBuyPrice+1680
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1680, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1739
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1680, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1736
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1670
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1035
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1092
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1855, 1680, 1680
                    , 1739, 1680, 1736, 1670, 1035, 1092)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1855, netSellCostBuyPrice = netSellCostBuyPrice+1680
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1680
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1739
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1680
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1736
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1670
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1035
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1092;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762df86b1e70 and sellbillId = 150072 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e00e841ca
-- ----------------------------------------------------------------------------------------------------

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-18 16:45:34', '06762e00e841ca', '1', '0.00', '0', '0', '1', '260.00', '260', '260', '0', '1', '2024-12-18 16:46:05', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150073', '0', '2024-12-18 16:46:05', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '260', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:45:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 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', '150073', '5', '15571', '1', '260', '260', '0', '', '1', '2024-12-18 16:46:05', '15571', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34419-1,','1','1','0','0','260','260','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 = 548300;
 INSERT INTO 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-18', 260, 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+260, 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-18', 260, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, 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 = '5', userid = '104', storedetaildate = '2024-12-18 16:46:05' WHERE storedetailid = '15570';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15571', '1', '1', '1', '150073', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-18 16:46:05','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '32500',  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 ('32240','260', '0', '1', 'اضافة فاتورة مبيعات', '150073', '32500', '2024-12-18 16:46: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-18', 260, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, 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;
 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-18', 260, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 260, 265, 265
                    , 265, 265, 265, 265, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+260, netSellCostBuyPrice = netSellCostBuyPrice+265
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+265
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+265
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+265
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+265
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+265
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e00e841ca and sellbillId = 150073 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:16:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:46:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:46:06', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:17:56";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:47:56", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:47:56', '77', 'add', '192.168.1.21', '', '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 ('06762dc1277b88', '2024-12-18 16:28:34', '23', '-5275.00', '-1775', '0', '0', '3500',  '3500', '0', '3500', '1', '2024-12-18 16:47: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 ('H1525', '14144', '14', '16487', '5', '700', '3500', '0', '', '2024-12-18 16:47:56', '16487','','','0','0','0','0','0',null,'700','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-18 16:28:34', 1, 16487, 0, 0
                    , 700, 5, 0, 0, 77, '2024-12-18 16:47:56')
                ON DUPLICATE KEY UPDATE buyprice = 700,
                        buyQuantity =buyQuantity+5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:47:56' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16487', '700', '5', '0', 'buyBillController.php', '32741', '', '0', '0');
UPDATE product SET  productBuyPrice = "700" WHERE productId = 16487 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32741 ;
UPDATE product SET productName = 'H1525', productDescription = '', productCatId = '14', productBuyPrice = '700.00', productSellAllPrice = '900.00', productSellUnitPrice = '900.00', productSellHalfPrice = '900.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1525',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '700',lastbuyprice_withDiscount = '700',meanbuyprice = '700',meanbuyprice_withDiscount = '700' , productbuypricereal = '700.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='700',meanbuyprice_withTax='700',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='700'  WHERE productId = '16487';
UPDATE buybilldetail SET  lastbuyprice = 700 , meanbuyprice = 700, lastbuyprice_withDiscount = 700, meanbuyprice_withDiscount = 700
        , lastbuyprice_withTax = 700, meanbuyprice_withTax = 700, lastbuyprice_withDiscountAndTax = 700
                where buybilldetailid = 32741;
UPDATE productunit SET proUnitBuyPrice  = 700 * productnumber WHERE productid = 16487;
UPDATE storedetail SET  productquantity = '5', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16486';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16487', '1', '5', '0', '14144', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '5', '77', '2024-12-18 16:28:34','0','0');
UPDATE supplier SET  suppliercurrentDebt = '-1775',suppliercurrentDebtInCurrency= '-1775' , userid = '77', supplierdate = '2024-12-18 16:47:56'   WHERE supplierid = '23';
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 ('23', '-5275.00', '3500', '0', 'اضافة فاتورة مشتريات', '14144', '-1775', '2024-12-18 16:28:34', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','3500','1','-5275','3500','-1775','0');
update buybill set dailyentryid='0,' where buybillid=14144;
COMMIT;
UPDATE product SET overAllAveragePrice = 700 WHERE productId = 16487;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:17:56";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:47:56", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:47:56', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14144');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:18:26";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:48:26", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:48:26', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:18:47";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:48:47", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:48:47', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e002bd78d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1600,@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-18 16:45:22', '06762e002bd78d', '1600', '0.00', '1515', '0', '1', '1515.00', '1515', '0', '1515', '1', '2024-12-18 16:48:47', '', '75', '0', 'رانيا نبيل الهرم 58', '2', '1', '3', '80', 'رانيا نبيل الهرم 58', '7' ,'0','','','','','-1','0','0','0','0','0','1515','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1515', userid = '75' WHERE clientid = '1600';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1600','0.00','1515','0','اضافة فاتورة مبيعات','150074', '1515', '2024-12-18 16:48:47', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1515', '0', null, '0', null, null,'', '0','1','1','1515','1','2024-12-18 16:45:22','0','0');
UPDATE client SET  inUse = 0 where clientid = 1600;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150074', '14', '16292', '2', '300', '600', '0', '', '1', '2024-12-18 16:48:47', '16292', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36360-2,','1','1','0','0','300','600','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 = 548301;
 INSERT INTO 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-18', 600, 460, 460
                    , 460, 460, 460, 460
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 460, 460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, 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+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-18', 600, 460, 460
                    , 460, 460, 460, 460
                    , 0, 0, 0, 0
                    , 0, 0, 0, 460, 460, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, 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 = '27', userid = '75', storedetaildate = '2024-12-18 16:48:47' WHERE storedetailid = '16291';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16292', '1', '2', '1', '150074', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29', '27', '75', '2024-12-18 16:48:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35932;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07123', '150074', '5', '16150', '1', '240', '240', '0', '', '1', '2024-12-18 16:48:47', '16150', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35932-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 184.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 184.00
        , lastbuyprice_withTax = 185, meanbuyprice_withTax = 182, lastbuyprice_withDiscountAndTax = 185
                where sellbilldetailid = 548302;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16150, '2024-12-18', 240, 185, 185
                    , 184, 185, 184, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 185, 182, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+182
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 240, 185, 185
                    , 184, 185, 184, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 185, 182, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+182
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:48:47' WHERE storedetailid = '16149';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16150', '1', '1', '1', '150074', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-18 16:48:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35787;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07121', '150074', '5', '16127', '1', '420', '420', '0', '', '1', '2024-12-18 16:48:47', '16127', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35787-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 358.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 358.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 356, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 548303;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16127, '2024-12-18', 420, 360, 360
                    , 358, 360, 358, 356.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 356, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+358
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+358
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+356.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , 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-18', 420, 360, 360
                    , 358, 360, 358, 356.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 356, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+358
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+358
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+356.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , 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 = '12', userid = '75', storedetaildate = '2024-12-18 16:48:47' WHERE storedetailid = '16126';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16127', '1', '1', '1', '150074', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-18 16:48:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35614;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07135', '150074', '5', '16161', '1', '220', '220', '0', '', '1', '2024-12-18 16:48:47', '16161', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35614-1,','1','1','0','0','220','220','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 = 548304;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16161, '2024-12-18', 220, 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+220, 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-18', 220, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, 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-18 16:48:47' WHERE storedetailid = '16160';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16161', '1', '1', '1', '150074', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-18 16:48: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', '150074', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 16:48: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', '150074', '17', '10291', '1', '15', '15', '0', '', '1', '2024-12-18 16:48:47', '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 = 80 where clientid = 1600;
 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-18', 1515, 1150, 1150
                    , 1147, 1150, 1147, 1141.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1150, 1143, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1515, sellCostBuyPrice =sellCostBuyPrice+1150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1147
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1147
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1141.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1143
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (1600, '2024-12-18', 1515, 1150, 1150
                    , 1147, 1150, 1147, 1141.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1150, 1143, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1515, sellCostBuyPrice =sellCostBuyPrice+1150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1147
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1147
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1141.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1143
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1515, 1150, 1150
                    , 1147, 1150, 1147, 1141.67, 1150, 1143)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1515, netSellCostBuyPrice = netSellCostBuyPrice+1150
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1150
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1147
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1150
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1147
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1141.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1150
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1143;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e002bd78d and sellbillId = 150074 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:18:48";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 16:48:48", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:48: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-18 13:18:55";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:48:55", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:48:55', '77', 'add', '192.168.1.21', '', '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 ('06762e0baef563', '2024-12-18 16:48:26', '23', '-1775.00', '5225', '0', '0', '7000',  '7000', '0', '7000', '1', '2024-12-18 16:48: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 ('H1525', '14145', '14', '16487', '10', '700', '7000', '0', '', '2024-12-18 16:48:56', '16487','','','0','0','0','0','0',null,'700','7000','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-18 16:48:26', 1, 16487, 0, 0
                    , 700, 10, 0, 0, 77, '2024-12-18 16:48:56')
                ON DUPLICATE KEY UPDATE buyprice = 700,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:48:56' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16487', '700', '10', '0', 'buyBillController.php', '32742', '', '0', '0');
UPDATE product SET  productBuyPrice = "700" WHERE productId = 16487 ;
UPDATE buybilldetail SET  quantitybefore = 5 WHERE buybilldetailid = 32742 ;
UPDATE product SET productName = 'H1525', productDescription = '', productCatId = '14', productBuyPrice = '700.00', productSellAllPrice = '900.00', productSellUnitPrice = '900.00', productSellHalfPrice = '900.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1525',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '700',lastbuyprice_withDiscount = '700',meanbuyprice = '700',meanbuyprice_withDiscount = '700' , productbuypricereal = '700.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='700',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='700',meanbuyprice_withTax='700',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='700'  WHERE productId = '16487';
UPDATE buybilldetail SET  lastbuyprice = 700 , meanbuyprice = 700, lastbuyprice_withDiscount = 700, meanbuyprice_withDiscount = 700
        , lastbuyprice_withTax = 700, meanbuyprice_withTax = 700, lastbuyprice_withDiscountAndTax = 700
                where buybilldetailid = 32742;
UPDATE productunit SET proUnitBuyPrice  = 700 * productnumber WHERE productid = 16487;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16486';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16487', '1', '10', '0', '14145', 'اضافة فاتورة مشتريات', 'buyBillController.php', '5', '15', '77', '2024-12-18 16:48:26','0','0');
UPDATE supplier SET  suppliercurrentDebt = '5225',suppliercurrentDebtInCurrency= '5225' , userid = '77', supplierdate = '2024-12-18 16:48:56'   WHERE supplierid = '23';
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 ('23', '-1775.00', '7000', '0', 'اضافة فاتورة مشتريات', '14145', '5225', '2024-12-18 16:48:26', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','7000','1','-1775','7000','5225','0');
update buybill set dailyentryid='0,' where buybillid=14145;
COMMIT;
UPDATE product SET overAllAveragePrice = 700 WHERE productId = 16487;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:18:56";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:48:56", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:48:56', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14145');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:19:01";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:49:01", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 16:49:01', '77', 'oneSupplier', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:19:13";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:49:13", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 16:49:13', '77', 'oneSupplier', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:19:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:49:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:49:21', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e02ea1bc6
-- ----------------------------------------------------------------------------------------------------

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-18 16:46:06', '06762e02ea1bc6', '1', '0.00', '0', '0', '1', '420.00', '420', '420', '0', '1', '2024-12-18 16:49:21', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '2' ,'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-18','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','اضافة فاتورة مبيعات','150075', '0', '2024-12-18 16:49:21', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '420', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:46:06','0','0');
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', '150075', '1', '15026', '1', '210', '210', '0', '', '1', '2024-12-18 16:49:21', '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 = 548307;
 INSERT INTO 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-18', 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-18', 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 = '3', userid = '104', storedetaildate = '2024-12-18 16:49:21' WHERE storedetailid = '15025';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15026', '1', '1', '1', '150075', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-18 16:49:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35282;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07023', '150075', '5', '15963', '1', '210', '210', '0', '', '1', '2024-12-18 16:49:21', '15963', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35282-1,','1','1','0','0','210','210','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 = 548308;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15963, '2024-12-18', 210, 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+210, 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-18', 210, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, 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 = '104', storedetaildate = '2024-12-18 16:49:21' WHERE storedetailid = '15962';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15963', '1', '1', '1', '150075', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-18 16:49:21','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '32920',  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 ('32500','420', '0', '1', 'اضافة فاتورة مبيعات', '150075', '32920', '2024-12-18 16:49:21', '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-18', 420, 345, 345
                    , 345, 345, 345, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , 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;
 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-18', 420, 345, 345
                    , 345, 345, 345, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 420, 345, 345
                    , 345, 345, 345, 345, 190, 190)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+420, netSellCostBuyPrice = netSellCostBuyPrice+345
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+345
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+345
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+345
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+345
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+345
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+190
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+190;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e02ea1bc6 and sellbillId = 150075 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:19:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:49:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:49:22', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:21:53";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:51:53", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:51:53', '77', 'bill', '192.168.1.21', '', '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 ('7327','','5','575','670', '670','670', '2024-12-18', '0', '77', '1', '07327', '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 (16491, 1,'2024-12-18 16:52:22',77)
                ON DUPLICATE KEY UPDATE productid = 16491, edited = 1, sysdate = '2024-12-18 16:52: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', '16491', '1', '2024-12-18', '77', '0','1649101','670','670','670','575','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16491', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16491', '1', '0', '0', '16491', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','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 ('7329','','5','210','260', '260','260', '2024-12-18', '0', '77', '1', '07329', '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 (16492, 1,'2024-12-18 16:52:39',77)
                ON DUPLICATE KEY UPDATE productid = 16492, edited = 1, sysdate = '2024-12-18 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', '16492', '1', '2024-12-18', '77', '0','1649201','260','260','260','210','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16492', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16492', '1', '0', '0', '16492', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:22:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:52:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:52:40', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=4');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:22:58";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:52:58", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:52:58', '77', 'add', '192.168.1.21', '', '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 ('06762e18937eb3', '2024-12-18 16:51:53', '175', '302395.00', '311295', '0', '0', '8900',  '8900', '0', '8900', '1', '2024-12-18 16:52: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 ('07327', '14146', '5', '16491', '10', '575', '5750', '0', '', '2024-12-18 16:52:58', '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-18 16:51:53', 1, 16491, 0, 0
                    , 575, 10, 0, 0, 77, '2024-12-18 16:52:58')
                ON DUPLICATE KEY UPDATE buyprice = 575,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:52:58' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16491', '575', '10', '0', 'buyBillController.php', '32743', '', '0', '0');
UPDATE product SET  productBuyPrice = "575" WHERE productId = 16491 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32743 ;
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='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 = '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 = 32743;
UPDATE productunit SET proUnitBuyPrice  = 575 * productnumber WHERE productid = 16491;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16490';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16491', '1', '10', '0', '14146', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-18 16:51:53','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 ('07329', '14146', '5', '16492', '15', '210', '3150', '0', '', '2024-12-18 16:52:58', '16492','','','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-18 16:51:53', 1, 16492, 0, 0
                    , 210, 15, 0, 0, 77, '2024-12-18 16:52:58')
                ON DUPLICATE KEY UPDATE buyprice = 210,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 16:52:58' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16492', '210', '15', '0', 'buyBillController.php', '32744', '', '0', '0');
UPDATE product SET  productBuyPrice = "210" WHERE productId = 16492 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32744 ;
UPDATE product SET productName = '7329', 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 = '07329',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 = '16492';
UPDATE buybilldetail SET  lastbuyprice = 210 , meanbuyprice = 210, lastbuyprice_withDiscount = 210, meanbuyprice_withDiscount = 210
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where buybilldetailid = 32744;
UPDATE productunit SET proUnitBuyPrice  = 210 * productnumber WHERE productid = 16492;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16491';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16492', '1', '15', '0', '14146', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 16:51:53','0','0');
UPDATE supplier SET  suppliercurrentDebt = '311295',suppliercurrentDebtInCurrency= '311295' , userid = '77', supplierdate = '2024-12-18 16:52:58'   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', '302395.00', '8900', '0', 'اضافة فاتورة مشتريات', '14146', '311295', '2024-12-18 16:51:53', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','8900','1','302395','8900','311295','0');
update buybill set dailyentryid='0,' where buybillid=14146;
COMMIT;
UPDATE product SET overAllAveragePrice = 575 WHERE productId = 16491;UPDATE product SET overAllAveragePrice = 210 WHERE productId = 16492;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:22:59";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:52:59", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:52:59', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14146');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:23:04";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:53:04", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 16:53:04', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14146&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:23:16";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:53:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:53:16', '2', 'addAndRetuen', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762df574a4f2
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6168,@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-18 16:42:31', '06762df574a4f2', '6168', '0.00', '2495', '0', '1', '2495.00', '2495', '0', '2495', '1', '2024-12-18 16:53:16', '', '2', '0', 'مارينا 99', '2', '1', '3', '82', 'مارينا 99', '10' ,'0','','','','','-1','0','0','0','0','0','2495','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '2495', userid = '2' WHERE clientid = '6168';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6168','0.00','2495','0','اضافة فاتورة مبيعات','150076', '2495', '2024-12-18 16:53:16', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2495', '0', null, '0', null, null,'', '0','1','1','2495','1','2024-12-18 16:42:31','0','0');
UPDATE client SET  inUse = 0 where clientid = 6168;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35219;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06950', '150076', '5', '15873', '1', '580', '580', '0', '', '1', '2024-12-18 16:53:16', '15873', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35219-1,','1','1','0','0','580','580','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
        , lastbuyprice_withTax = 520, meanbuyprice_withTax = 520, lastbuyprice_withDiscountAndTax = 520
                where sellbilldetailid = 548309;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15873, '2024-12-18', 580, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 520, 520, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+520
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+520
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 580, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 520, 520, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+520
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+520
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:53:16' WHERE storedetailid = '15872';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15873', '1', '1', '1', '150076', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '2', '2024-12-18 16:53:16','0','0');
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', '150076', '5', '16284', '1', '200', '200', '0', '', '1', '2024-12-18 16:53:16', '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 = 548310;
 INSERT INTO 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-18', 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-18', 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-18 16:53:16' WHERE storedetailid = '16283';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16284', '1', '1', '1', '150076', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '2', '2024-12-18 16:53:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36057;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150076', '5', '16347', '1', '200', '200', '0', '', '1', '2024-12-18 16:53:16', '16347', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36057-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 = 548311;
 INSERT INTO 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-18', 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-18', 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 = '14', userid = '2', storedetaildate = '2024-12-18 16:53:16' WHERE storedetailid = '16346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16347', '1', '1', '1', '150076', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '2', '2024-12-18 16:53:16','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', '150076', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-18 16:53:16', '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 = 548312;
 INSERT INTO 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-18', 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-18', 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 = '37', userid = '2', storedetaildate = '2024-12-18 16:53:16' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '150076', 'اضافة فاتورة مبيعات', 'sellbillController.php', '38', '37', '2', '2024-12-18 16:53:16','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', '150076', '5', '16122', '1', '380', '380', '0', '', '1', '2024-12-18 16:53:16', '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 = 548313;
 INSERT INTO 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-18', 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-18', 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 = '13', userid = '2', storedetaildate = '2024-12-18 16:53:16' WHERE storedetailid = '16121';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16122', '1', '1', '1', '150076', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '2', '2024-12-18 16:53:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33701;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06674', '150076', '5', '15187', '1', '490', '490', '0', '', '1', '2024-12-18 16:53:16', '15187', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33701-1,','1','1','0','0','490','490','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 566.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 566.00
        
                where sellbilldetailid = 548314;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15187, '2024-12-18', 490, 495, 495
                    , 566, 495, 566, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+566
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+566
                            , 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-18', 490, 495, 495
                    , 566, 495, 566, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+566
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+566
                            , 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-18 16:53:16' WHERE storedetailid = '15186';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15187', '1', '1', '1', '150076', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '2', '2024-12-18 16:53:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150076', '5', '16247', '2', '200', '400', '0', '', '1', '2024-12-18 16:53:16', '16247', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36295-2,','1','1','0','0','200','400','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 = 548315;
 INSERT INTO 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-18', 400, 280, 280
                    , 116, 280, 116, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 280, 50, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+116
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+116
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+50
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 400, 280, 280
                    , 116, 280, 116, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 50, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+116
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+116
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+50
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:53:16' WHERE storedetailid = '16246';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16247', '1', '2', '1', '150076', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '6', '2', '2024-12-18 16:53: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', '150076', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 16:53: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', '150076', '17', '10291', '1', '25', '25', '0', '', '1', '2024-12-18 16:53:17', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','25','25','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 82 where clientid = 6168;
 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-18', 2495, 2085, 2085
                    , 1989, 2085, 1989, 2080
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1590, 1347, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2495, sellCostBuyPrice =sellCostBuyPrice+2085
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2085, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1989
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2085, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1989
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2080
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1590
                            , 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6168, '2024-12-18', 2495, 2085, 2085
                    , 1989, 2085, 1989, 2080
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1590, 1347, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2495, sellCostBuyPrice =sellCostBuyPrice+2085
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2085, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1989
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2085, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1989
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2080
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1590
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2495, 2085, 2085
                    , 1989, 2085, 1989, 2080, 1590, 1347)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2495, netSellCostBuyPrice = netSellCostBuyPrice+2085
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2085
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1989
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2085
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1989
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2080
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1590
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1347;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762df574a4f2 and sellbillId = 150076 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:23:17";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:53:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:53:17', '2', '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-18 13:23:39";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:53:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:53:39', '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-18 13:23:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:53:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:53:49', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e1b8b234b
-- ----------------------------------------------------------------------------------------------------

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-18 16:52:40', '06762e1b8b234b', '1', '0.00', '0', '0', '1', '-450.00', '-450', '-450', '0', '1', '2024-12-18 16:53:49', '', '104', '0', 'نقدي', '1', '0', '4', '0', '300', '750', 'نقدي', '1', '1', '0', '', '', '','','-1','0','0','0','','0','-450','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','1','اضافة فاتورة مبيعات ومردودات','119', '0', '2024-12-18 16:53:49', '104', 'sellbillandruternController.php', 'اضافة فاتورة مبيعات ومردودات', '450', '0', null, '0', null, null,'', '0','1','1','-0','1','2024-12-18 16:52:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36149;
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 ('240','H1594', '119', '14', '16208', '1', '300', '300.00', '0', '', '0', '2024-12-18 16:53:49', '0', '16208', '0.00', '-1', '1','0','','','0','0','0','0','0','0','36149-1,','1','1','','0','0','300','300','0','','','0');
UPDATE sellandruternbilldetail 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 = 308;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16208, '2024-12-18', 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-18', 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 = '24', userid = '104', storedetaildate = '2024-12-18 16:53:49' WHERE storedetailid = '16207';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16208', '1', '1', '1', '119', 'فاتوره مبيعات ومردودات', 'sellbillandruternController.php', '25', '24', '104', '2024-12-18 16:53:49','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 ('630.00','H1593', '119', '14', '16227', '1', '750', '750', '0', '', '0', '2024-12-18 16:53:49', '1', '16227', '0.00', '-1', '1','0','','','0','0','0','0','0','0','','1','1','','0','0','750','750','0','','','0');
UPDATE sellandruternbilldetail 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 = 309;
 INSERT INTO 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 750, 630, 630, 630
                    , 630, 630, 630, 0, 1, 0, 0, 630, 630)
                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+750, returnSellCostBuyPrice = returnSellCostBuyPrice+630, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+630
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+630, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+630
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+630
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+630
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+630
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+630
                        , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 750, 630, 630, 630
                    , 630, 630, 630, 0, 0, 630, 630)
                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+750, returnSellCostBuyPrice = returnSellCostBuyPrice+630, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+630
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+630, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+630
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+630
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+630
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+630
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+630;
UPDATE storedetail SET  productquantity = '1', userid = '104', storedetaildate = '2024-12-18 16:53:49' WHERE storedetailid = '16226';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16227', '1', '1', '0', '119', 'اضافة فاتورة مردودات مبيعات', 'sellbillandruternController.php', '0', '1', '104', '2024-12-18 16:53:49','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '32470',  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 ('32920','450', '1', '1', 'اضافة فاتورة مبيعات ومردودات', '119', '32470', '2024-12-18 16:53:49', '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-18', 300, 240, 240
                    , 240, 240, 240, 240
                    , 750, 630, 630, 630
                    , 630, 630, 630 ,240, 240, 630, 630)
                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+750, returnSellCostBuyPrice = returnSellCostBuyPrice+630, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+630
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+630, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+630
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+630
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+630
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+630
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+630;
 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-18', 300, 240, 240
                    , 240, 240, 240, 240
                    , 750, 630, 630, 630
                    , 630, 630, 630 ,240, 240, 630, 630)
                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+750, returnSellCostBuyPrice = returnSellCostBuyPrice+630, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+630
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+630, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+630
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+630
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+630
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+630
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+630;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -450, -390, -390
                    , -390, -390, -390, -390, -390, -390)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-450, 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 06762e1b8b234b and sellbillId = 119 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:23:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:53:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-18 16:53:50', '104', 'editprint', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=editprint&id=119');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:23:52";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:53:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:53: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-18 13:24:00";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:54:00", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 16:54:00', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14146&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:24:02";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:54:02", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:54:02', '2', 'editsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150033');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:24:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:54:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:54:06', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:24:07";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 16:54:07", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 16:54:07', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:24:30";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:54:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:54:30', '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 = 150033 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


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

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150033;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 16:54:30', userid = '75',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '150033';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 21382;
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
        
                where sellbilldetailid = 548050;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9779, '2024-12-18', 510, 475, 475
                    , 475, 475, 475, 475
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-510, sellCostBuyPrice =sellCostBuyPrice-475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-475, sellCostMeanBuyPrice = sellCostMeanBuyPrice-475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-475
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 510, 475, 475
                    , 475, 475, 475, 475
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-510, sellCostBuyPrice =sellCostBuyPrice-475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-475, sellCostMeanBuyPrice = sellCostMeanBuyPrice-475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-475
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 16:54:30' WHERE storedetailid = '9778';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9779', '1', '1', '0', '150033', 'تعديل فاتورة مبيعات', 'sellbillController.php', '5', '6', '2', '2024-12-18 14:45:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 30964;
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 264.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 264.00
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 66, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 548051;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13108, '2024-12-18', 185, 265, 265
                    , 264, 265, 264, 253.33
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 265, 66, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-185, sellCostBuyPrice =sellCostBuyPrice-265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-265, sellCostMeanBuyPrice = sellCostMeanBuyPrice-264
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-264
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-253.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-66
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 185, 265, 265
                    , 264, 265, 264, 253.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 66, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-185, sellCostBuyPrice =sellCostBuyPrice-265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-265, sellCostMeanBuyPrice = sellCostMeanBuyPrice-264
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-264
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-253.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-66
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 16:54:30' WHERE storedetailid = '13107';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13108', '1', '1', '0', '150033', 'تعديل فاتورة مبيعات', 'sellbillController.php', '4', '5', '2', '2024-12-18 14:45:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35272;
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 = 548052;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15935, '2024-12-18', 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-18', 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 = '29', userid = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '15934';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15935', '1', '1', '0', '150033', 'تعديل فاتورة مبيعات', 'sellbillController.php', '28', '29', '2', '2024-12-18 14:45:48','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 184.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 184.00
        
                where sellbilldetailid = 548053;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13152, '2024-12-18', 105, 185, 185
                    , 184, 185, 184, 177.6
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-105, sellCostBuyPrice =sellCostBuyPrice-185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-185, sellCostMeanBuyPrice = sellCostMeanBuyPrice-184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-177.6
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 105, 185, 185
                    , 184, 185, 184, 177.6
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-105, sellCostBuyPrice =sellCostBuyPrice-185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-185, sellCostMeanBuyPrice = sellCostMeanBuyPrice-184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-177.6
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 16:54:30' WHERE storedetailid = '13151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13152', '1', '1', '0', '150033', 'تعديل فاتورة مبيعات', 'sellbillController.php', '10', '11', '2', '2024-12-18 14:45:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 33859;
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where sellbilldetailid = 548054;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15273, '2024-12-18', 210, 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-210, 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-18', 210, 250, 250
                    , 250, 250, 250, 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-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 = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '15272';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15273', '1', '1', '0', '150033', 'تعديل فاتورة مبيعات', 'sellbillController.php', '2', '3', '2', '2024-12-18 14:45:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 32363;
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        
                where sellbilldetailid = 548055;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14576, '2024-12-18', 175, 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-175, 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-18', 175, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-175, 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 = '3', userid = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '14575';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14576', '1', '1', '0', '150033', 'تعديل فاتورة مبيعات', 'sellbillController.php', '2', '3', '2', '2024-12-18 14:45:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 32813;
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 270.00
        
                where sellbilldetailid = 548056;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14785, '2024-12-18', 130, 210, 210
                    , 270, 210, 270, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-130, sellCostBuyPrice =sellCostBuyPrice-210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-210, sellCostMeanBuyPrice = sellCostMeanBuyPrice-270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-270
                            , 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-18', 130, 210, 210
                    , 270, 210, 270, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-130, sellCostBuyPrice =sellCostBuyPrice-210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-210, sellCostMeanBuyPrice = sellCostMeanBuyPrice-270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-270
                            , 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 = '5', userid = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '14784';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14785', '1', '1', '0', '150033', 'تعديل فاتورة مبيعات', 'sellbillController.php', '4', '5', '2', '2024-12-18 14:45:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35306;
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
        , lastbuyprice_withTax = 320, meanbuyprice_withTax = 320, lastbuyprice_withDiscountAndTax = 320
                where sellbilldetailid = 548057;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15909, '2024-12-18', 370, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-370, 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-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 370, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-370, 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 = '25', userid = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '15908';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15909', '1', '1', '0', '150033', 'تعديل فاتورة مبيعات', 'sellbillController.php', '24', '25', '2', '2024-12-18 14:45:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35895;
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 = 548058;
 INSERT INTO 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-18', 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-18', 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 = '28', userid = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '16291';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16292', '1', '1', '0', '150033', 'تعديل فاتورة مبيعات', 'sellbillController.php', '27', '28', '2', '2024-12-18 14:45:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 34153;
UPDATE sellbilldetail SET  lastbuyprice = 205.00 , meanbuyprice = 205.00, lastbuyprice_withDiscount = 205.00, meanbuyprice_withDiscount = 205.00
        
                where sellbilldetailid = 548059;
 INSERT INTO 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-18', 190, 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-190, 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-18', 190, 205, 205
                    , 205, 205, 205, 205
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-190, 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 = '5', userid = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '15435';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15436', '1', '1', '0', '150033', 'تعديل فاتورة مبيعات', 'sellbillController.php', '4', '5', '2', '2024-12-18 14:45:48','0','0');
CALL clientInUse(8799,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-500', userid = '2' WHERE clientid = '8799';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8799','1919.00','2419.00','1','تعديل فاتورة مبيعات','150033', '-500', '2024-12-18 14:45:48', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '2419', '0', null, '0', null, null,'', '0','1','1','2419','1','2024-12-18 14:45:48','0','0');
UPDATE client SET  inUse = 0 where clientid = 8799;
 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-18', 2419, 2475, 2475
                    , 2533, 2475, 2533, 2455.93
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,960, 761, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-2419, sellCostBuyPrice =sellCostBuyPrice-2475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-2475, sellCostMeanBuyPrice = sellCostMeanBuyPrice-2533
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-2475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-2533
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-2455.93
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-960
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-761
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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 (8799, '2024-12-18', 2419, 2475, 2475
                    , 2533, 2475, 2533, 2455.93
                    , 0, 0, 0, 0
                    , 0, 0, 0, 960, 761, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-2419, sellCostBuyPrice =sellCostBuyPrice-2475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-2475, sellCostMeanBuyPrice = sellCostMeanBuyPrice-2533
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-2475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-2533
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-2455.93
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-960
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-761
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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, 2419, 2475, 2475
                    , 2533, 2475, 2533, 2455.93, 960, 761)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-2419, netSellCostBuyPrice = netSellCostBuyPrice-2475
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-2475
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-2533
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-2475
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-2533
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-2455.93
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-960
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-761;

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


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

COMMIT;
BEGIN;
CALL clientInUse(8799,@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 14:45:48', '06762c3fcaa4b0', '8799', '-500.00', '1879', '0', '1', '2379', '2379', '0', '2379', '1', '2024-12-18 14:45:48', '', '2', '0', 'دلال فوزي', '2', '1', '3', '83', 'دلال فوزي', '12', '150033', '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 = '1879', userid = '2' WHERE clientid = '8799';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8799','-500.00','2379','0','اضافة فاتورة مبيعات (معدله)','150077', '1879', '2024-12-18 16:54:30', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '2379', '0', null, '0', null, null,'', '0','1','1','2419','1','2024-12-18 14:45:48','0','0');
UPDATE client SET  inUse = 0 where clientid = 8799;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 21382;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('475','H1141', '150077', '14', '9779', '1', '510', '510', '0', '', '1', '2024-12-18 16:54:30', '9779', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','21382-1,','1','1','0','0','510','510','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
        
                where sellbilldetailid = 548318;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9779, '2024-12-18', 510, 475, 475
                    , 475, 475, 475, 475
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+475
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 510, 475, 475
                    , 475, 475, 475, 475
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+475
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:54:30' WHERE storedetailid = '9778';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9779', '1', '1', '1', '150077', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '6', '5', '2', '2024-12-18 16:54:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30964;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2671', '150077', '1', '13108', '1', '145', '145', '0', '', '1', '2024-12-18 16:54:30', '13108', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30964-1,','1','1','0','0','145','145','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 264.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 264.00
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 66, lastbuyprice_withDiscountAndTax = 265
                where sellbilldetailid = 548319;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13108, '2024-12-18', 145, 265, 265
                    , 264, 265, 264, 253.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 265, 66, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+145, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+264
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+264
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+253.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+66
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 145, 265, 265
                    , 264, 265, 264, 253.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 265, 66, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+145, sellCostBuyPrice =sellCostBuyPrice+265
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+265, sellCostMeanBuyPrice = sellCostMeanBuyPrice+264
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+265, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+264
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+253.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+66
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:54:30' WHERE storedetailid = '13107';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13108', '1', '1', '1', '150077', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '5', '4', '2', '2024-12-18 16:54:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35272;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3297', '150077', '1', '15935', '1', '200', '200', '0', '', '1', '2024-12-18 16:54:30', '15935', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35272-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 = 548320;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15935, '2024-12-18', 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-18', 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 = '28', userid = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '15934';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15935', '1', '1', '1', '150077', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '29', '28', '2', '2024-12-18 16:54: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 ('185','B1128', '150077', '2', '13152', '1', '105', '105', '0', '', '1', '2024-12-18 16:54:30', '13152', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','105','105','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 184.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 184.00
        
                where sellbilldetailid = 548321;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13152, '2024-12-18', 105, 185, 185
                    , 184, 185, 184, 177.6
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+105, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+177.6
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 105, 185, 185
                    , 184, 185, 184, 177.6
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+105, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+177.6
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:54:30' WHERE storedetailid = '13151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13152', '1', '1', '1', '150077', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '11', '10', '2', '2024-12-18 16:54:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33859;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06733', '150077', '5', '15273', '1', '210', '210', '0', '', '1', '2024-12-18 16:54:30', '15273', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33859-1,','1','1','0','0','210','210','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 = 548322;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15273, '2024-12-18', 210, 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+210, 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-18', 210, 250, 250
                    , 250, 250, 250, 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+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 = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '15272';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15273', '1', '1', '1', '150077', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '3', '2', '2', '2024-12-18 16:54:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32363;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2977', '150077', '1', '14576', '1', '175', '175', '0', '', '1', '2024-12-18 16:54:30', '14576', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32363-1,','1','1','0','0','175','175','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 = 548323;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14576, '2024-12-18', 175, 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+175, 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-18', 175, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+175, 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 = '2', userid = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '14575';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14576', '1', '1', '1', '150077', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '3', '2', '2', '2024-12-18 16:54:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32813;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06470', '150077', '5', '14785', '1', '130', '130', '0', '', '1', '2024-12-18 16:54:30', '14785', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32813-1,','1','1','0','0','130','130','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 270.00
        
                where sellbilldetailid = 548324;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14785, '2024-12-18', 130, 210, 210
                    , 270, 210, 270, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , 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-18', 130, 210, 210
                    , 270, 210, 270, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , 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 = '4', userid = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '14784';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14785', '1', '1', '1', '150077', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '5', '4', '2', '2024-12-18 16:54:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35306;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1487', '150077', '14', '15909', '1', '370', '370', '0', '', '1', '2024-12-18 16:54:30', '15909', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35306-1,','1','1','0','0','370','370','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 = 320, lastbuyprice_withDiscountAndTax = 320
                where sellbilldetailid = 548325;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15909, '2024-12-18', 370, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, 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+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 370, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, 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 = '24', userid = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '15908';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15909', '1', '1', '1', '150077', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '25', '24', '2', '2024-12-18 16:54:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35895;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150077', '14', '16292', '1', '300', '300', '0', '', '1', '2024-12-18 16:54:30', '16292', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35895-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 = 548326;
 INSERT INTO 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-18', 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-18', 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 = '27', userid = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '16291';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16292', '1', '1', '1', '150077', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '28', '27', '2', '2024-12-18 16:54:30','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', '150077', '5', '15436', '1', '190', '190', '0', '', '1', '2024-12-18 16:54:30', '15436', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34153-1,','1','1','0','0','190','190','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 = 548327;
 INSERT INTO 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-18', 190, 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+190, 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-18', 190, 205, 205
                    , 205, 205, 205, 205
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, 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 = '4', userid = '2', storedetaildate = '2024-12-18 16:54:30' WHERE storedetailid = '15435';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15436', '1', '1', '1', '150077', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '5', '4', '2', '2024-12-18 16:54: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', '150077', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 16:54:31', '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', '150077', '17', '10291', '1', '24', '24', '0', '', '1', '2024-12-18 16:54:31', '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');
 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-18', 2379, 2475, 2475
                    , 2533, 2475, 2533, 2455.93
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,960, 761, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2379, sellCostBuyPrice =sellCostBuyPrice+2475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2533
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2533
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2455.93
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+960
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+761
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (8799, '2024-12-18', 2379, 2475, 2475
                    , 2533, 2475, 2533, 2455.93
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,960, 761, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2379, sellCostBuyPrice =sellCostBuyPrice+2475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2533
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2533
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2455.93
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+960
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+761
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 2379, 2475, 2475
                    , 2533, 2475, 2533, 2455.93, 960, 761)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2379, netSellCostBuyPrice = netSellCostBuyPrice+2475
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2475
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2533
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2475
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2533
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2455.93
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+960
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+761;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150033 and newid=150077 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:24:31";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:54:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:54:31', '2', 'editprint', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150077');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:25:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:55:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:55:10', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e20e767cf
-- ----------------------------------------------------------------------------------------------------

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-18 16:54:06', '06762e20e767cf', '1', '0.00', '0', '0', '1', '285.00', '285', '285', '0', '1', '2024-12-18 16:55:10', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','285','0','','0','0','285','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150078', '0', '2024-12-18 16:55:10', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '285', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:54:06','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', '150078', '5', '16091', '1', '285', '285', '0', '', '1', '2024-12-18 16:55:10', '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 = 548330;
 INSERT INTO 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-18', 285, 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+285, 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-18', 285, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+285, 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 = '23', userid = '104', storedetaildate = '2024-12-18 16:55:10' WHERE storedetailid = '16090';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16091', '1', '1', '1', '150078', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '104', '2024-12-18 16:55:10','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '32755',  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 ('32470','285', '0', '1', 'اضافة فاتورة مبيعات', '150078', '32755', '2024-12-18 16:55:10', '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-18', 285, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+285, 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;
 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-18', 285, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+285, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 285, 235, 235
                    , 235, 235, 235, 235, 235, 235)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+285, netSellCostBuyPrice = netSellCostBuyPrice+235
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+235
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+235
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+235
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+235
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+235
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+235
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+235;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e20e767cf and sellbillId = 150078 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:25:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:55:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:55:11', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:25:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:55:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 16:55:19', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:25:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:55:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 16:55:30', '104', 'add', '192.168.1.13', '', '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-18', '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 = '32705',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('32755.00','50', '1', '1', 'إضافة مصروف', '25823', '32705', '2024-12-18 16:55:30', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'الاء عماد ', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-18', 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 = '25823';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:25:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:55:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 16:55:30', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:25:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:55:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 16:55:32', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:26:12";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:56:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:56: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-18 13:26:24";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:56:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:56:24', '2', 'editsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150076');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:26:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:56:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:56:25', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:26:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:56:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:56:46', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e299b5efb
-- ----------------------------------------------------------------------------------------------------

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-18 16:56:25', '06762e299b5efb', '1', '0.00', '0', '0', '1', '20.00', '20', '20', '0', '1', '2024-12-18 16:56:46', '', '104', '0', 'نقدي', '1', '0', '3', '81', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','20','0','','0','0','20','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150079', '0', '2024-12-18 16:56:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '20', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:56: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 ('0','10291', '150079', '17', '10291', '1', '20', '20', '0', '', '1', '2024-12-18 16:56:46', '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');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '32725',  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 ('32705','20', '0', '1', 'اضافة فاتورة مبيعات', '150079', '32725', '2024-12-18 16:56:46', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 81 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-18', 20, 0, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+20, 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+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 20, 0, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+20, 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+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 20, 0, 0
                    , 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+20, netSellCostBuyPrice = netSellCostBuyPrice+0
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+0
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+0
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+0
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+0
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e299b5efb and sellbillId = 150079 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:26:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:56:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:56:47', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:27:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:57:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 16:57:02', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:27:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:57:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:57:06', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:27:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:57:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 16:57:15', '104', 'add', '192.168.1.13', '', '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', '2040', '2024-12-18', '104', '0', '0','','1','1','0','0','2040');
UPDATE save SET  savecurrentvalue = '30685',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('32725.00','2040', '1', '1', 'تحويل امول الى الخزنة  [ فودافون كاش ] ', '3522', '30685', '2024-12-18 16:57:15', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '222286.5',  userid = '104' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('220246.50','2040', '0', '2', 'تحويل امول من الخزنة  [ نقدي ] ', '3522', '222286.5', '2024-12-18 16:57:15', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '2', transfermoneyvalue = '2040.00', transfermoneydate = '2024-12-18', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='2040' WHERE transfermoneyid = '3522';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:27:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:57:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 16:57:15', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:27:16";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:57:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:57:16', '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 = 150076 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


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

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150076;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 16:57:16', userid = '2',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '150076';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35219;
UPDATE sellbilldetail SET  lastbuyprice = 520.00 , meanbuyprice = 520.00, lastbuyprice_withDiscount = 520.00, meanbuyprice_withDiscount = 520.00
        , lastbuyprice_withTax = 520, meanbuyprice_withTax = 520, lastbuyprice_withDiscountAndTax = 520
                where sellbilldetailid = 548309;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15873, '2024-12-18', 580, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 520, 520, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-580, sellCostBuyPrice =sellCostBuyPrice-520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-520, sellCostMeanBuyPrice = sellCostMeanBuyPrice-520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-520
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-520
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 580, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 520, 520, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-580, sellCostBuyPrice =sellCostBuyPrice-520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-520, sellCostMeanBuyPrice = sellCostMeanBuyPrice-520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-520
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-520
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 16:57:16' WHERE storedetailid = '15872';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15873', '1', '1', '0', '150076', 'تعديل فاتورة مبيعات', 'sellbillController.php', '6', '7', '2', '2024-12-18 16:42:31','0','0');
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 = 548310;
 INSERT INTO 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-18', 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-18', 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 = '10', userid = '2', storedetaildate = '2024-12-18 16:57:16' WHERE storedetailid = '16283';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16284', '1', '1', '0', '150076', 'تعديل فاتورة مبيعات', 'sellbillController.php', '9', '10', '2', '2024-12-18 16:42:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36057;
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 = 548311;
 INSERT INTO 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-18', 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-18', 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 = '15', userid = '2', storedetaildate = '2024-12-18 16:57:16' WHERE storedetailid = '16346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16347', '1', '1', '0', '150076', 'تعديل فاتورة مبيعات', 'sellbillController.php', '14', '15', '2', '2024-12-18 16:42:31','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 = 548312;
 INSERT INTO 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-18', 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-18', 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 = '38', userid = '2', storedetaildate = '2024-12-18 16:57:16' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '0', '150076', 'تعديل فاتورة مبيعات', 'sellbillController.php', '37', '38', '2', '2024-12-18 16:42:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35788;
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 = 548313;
 INSERT INTO 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-18', 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-18', 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 = '14', userid = '2', storedetaildate = '2024-12-18 16:57:16' WHERE storedetailid = '16121';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16122', '1', '1', '0', '150076', 'تعديل فاتورة مبيعات', 'sellbillController.php', '13', '14', '2', '2024-12-18 16:42:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 33701;
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 566.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 566.00
        
                where sellbilldetailid = 548314;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15187, '2024-12-18', 490, 495, 495
                    , 566, 495, 566, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-490, sellCostBuyPrice =sellCostBuyPrice-495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-495, sellCostMeanBuyPrice = sellCostMeanBuyPrice-566
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-566
                            , 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-18', 490, 495, 495
                    , 566, 495, 566, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-490, sellCostBuyPrice =sellCostBuyPrice-495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-495, sellCostMeanBuyPrice = sellCostMeanBuyPrice-566
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-566
                            , 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-18 16:57:16' WHERE storedetailid = '15186';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15187', '1', '1', '0', '150076', 'تعديل فاتورة مبيعات', 'sellbillController.php', '4', '5', '2', '2024-12-18 16:42:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-2 where id = 36295;
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 = 548315;
 INSERT INTO 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-18', 400, 280, 280
                    , 116, 280, 116, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 280, 50, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-400, sellCostBuyPrice =sellCostBuyPrice-280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-280, sellCostMeanBuyPrice = sellCostMeanBuyPrice-116
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-116
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-50
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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-18', 400, 280, 280
                    , 116, 280, 116, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 50, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-400, sellCostBuyPrice =sellCostBuyPrice-280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-280, sellCostMeanBuyPrice = sellCostMeanBuyPrice-116
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-116
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-50
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 16:57:16' WHERE storedetailid = '16246';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16247', '1', '2', '0', '150076', 'تعديل فاتورة مبيعات', 'sellbillController.php', '6', '8', '2', '2024-12-18 16:42:31','0','0');
CALL clientInUse(6168,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '2' WHERE clientid = '6168';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6168','2495.00','2495.00','1','تعديل فاتورة مبيعات','150076', '0', '2024-12-18 16:42:31', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '2495', '0', null, '0', null, null,'', '0','1','1','2495','1','2024-12-18 16:42:31','0','0');
UPDATE client SET  inUse = 0 where clientid = 6168;
 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-18', 2495, 2085, 2085
                    , 1989, 2085, 1989, 2080
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1590, 1347, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-2495, sellCostBuyPrice =sellCostBuyPrice-2085
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-2085, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1989
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-2085, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1989
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-2080
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1590
                            , 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6168, '2024-12-18', 2495, 2085, 2085
                    , 1989, 2085, 1989, 2080
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1590, 1347, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-2495, sellCostBuyPrice =sellCostBuyPrice-2085
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-2085, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1989
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-2085, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1989
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-2080
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1590
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2495, 2085, 2085
                    , 1989, 2085, 1989, 2080, 1590, 1347)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-2495, netSellCostBuyPrice = netSellCostBuyPrice-2085
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-2085
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-1989
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-2085
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-1989
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-2080
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-1590
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-1347;

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


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

COMMIT;
BEGIN;
CALL clientInUse(6168,@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 16:42:31', '06762df574a4f2', '6168', '0.00', '2919', '0', '1', '2919', '2919', '0', '2919', '1', '2024-12-18 16:42:31', '', '2', '0', 'مارينا 99', '2', '1', '3', '82', 'مارينا 99', '11', '150076', '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 = '2919', userid = '2' WHERE clientid = '6168';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6168','0.00','2919','0','اضافة فاتورة مبيعات (معدله)','150080', '2919', '2024-12-18 16:57:16', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '2919', '0', null, '0', null, null,'', '0','1','1','2495','1','2024-12-18 16:42:31','0','0');
UPDATE client SET  inUse = 0 where clientid = 6168;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35219;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06950', '150080', '5', '15873', '1', '580', '580', '0', '', '1', '2024-12-18 16:57:16', '15873', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35219-1,','1','1','0','0','580','580','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
        , lastbuyprice_withTax = 520, meanbuyprice_withTax = 520, lastbuyprice_withDiscountAndTax = 520
                where sellbilldetailid = 548332;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15873, '2024-12-18', 580, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 520, 520, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+520
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+520
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 580, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 520, 520, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+520
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+520
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:57:16' WHERE storedetailid = '15872';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15873', '1', '1', '1', '150080', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '7', '6', '2', '2024-12-18 16:57:16','0','0');
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', '150080', '5', '16284', '1', '200', '200', '0', '', '1', '2024-12-18 16:57:16', '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 = 548333;
 INSERT INTO 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-18', 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-18', 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-18 16:57:16' WHERE storedetailid = '16283';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16284', '1', '1', '1', '150080', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '10', '9', '2', '2024-12-18 16:57:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36057;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150080', '5', '16347', '1', '200', '200', '0', '', '1', '2024-12-18 16:57:16', '16347', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36057-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 = 548334;
 INSERT INTO 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-18', 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-18', 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 = '14', userid = '2', storedetaildate = '2024-12-18 16:57:17' WHERE storedetailid = '16346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16347', '1', '1', '1', '150080', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '15', '14', '2', '2024-12-18 16:57:17','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', '150080', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-18 16:57:17', '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 = 548335;
 INSERT INTO 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-18', 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-18', 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 = '37', userid = '2', storedetaildate = '2024-12-18 16:57:17' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '150080', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '38', '37', '2', '2024-12-18 16:57:17','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', '150080', '5', '16122', '1', '380', '380', '0', '', '1', '2024-12-18 16:57:17', '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 = 548336;
 INSERT INTO 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-18', 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-18', 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 = '13', userid = '2', storedetaildate = '2024-12-18 16:57:17' WHERE storedetailid = '16121';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16122', '1', '1', '1', '150080', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '14', '13', '2', '2024-12-18 16:57:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33701;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06674', '150080', '5', '15187', '1', '490', '490', '0', '', '1', '2024-12-18 16:57:17', '15187', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33701-1,','1','1','0','0','490','490','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 566.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 566.00
        
                where sellbilldetailid = 548337;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15187, '2024-12-18', 490, 495, 495
                    , 566, 495, 566, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+566
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+566
                            , 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-18', 490, 495, 495
                    , 566, 495, 566, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+566
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+566
                            , 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-18 16:57:17' WHERE storedetailid = '15186';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15187', '1', '1', '1', '150080', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '5', '4', '2', '2024-12-18 16:57:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150080', '5', '16247', '2', '200', '400', '0', '', '1', '2024-12-18 16:57:17', '16247', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36295-2,','1','1','0','0','200','400','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 = 548338;
 INSERT INTO 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-18', 400, 280, 280
                    , 116, 280, 116, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 280, 50, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+116
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+116
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+50
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 400, 280, 280
                    , 116, 280, 116, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 50, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+116
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+116
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+50
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 16:57:17' WHERE storedetailid = '16246';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16247', '1', '2', '1', '150080', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '8', '6', '2', '2024-12-18 16:57: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', '150080', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 16:57: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', '150080', '17', '10291', '1', '29', '29', '0', '', '1', '2024-12-18 16:57:17', '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 buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35884;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','44916', '150080', '5', '16210', '1', '420', '420', '0', '', '1', '2024-12-18 16:57:17', '16210', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35884-1,','1','1','0','0','420','420','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 = 548341;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16210, '2024-12-18', 420, 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+420, 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-18', 420, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, 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 = '2', storedetaildate = '2024-12-18 16:57:17' WHERE storedetailid = '16209';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16210', '1', '1', '1', '150080', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '12', '11', '2', '2024-12-18 16:57:17','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-18', 2919, 2460, 2460
                    , 2364, 2460, 2364, 2455
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1965, 1722, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2919, sellCostBuyPrice =sellCostBuyPrice+2460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2364
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2364
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2455
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1965
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1722
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (6168, '2024-12-18', 2919, 2460, 2460
                    , 2364, 2460, 2364, 2455
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1965, 1722, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2919, sellCostBuyPrice =sellCostBuyPrice+2460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2364
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2364
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2455
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1965
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1722
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 2919, 2460, 2460
                    , 2364, 2460, 2364, 2455, 1965, 1722)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2919, netSellCostBuyPrice = netSellCostBuyPrice+2460
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2460
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2364
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2460
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2364
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2455
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1965
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1722;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150076 and newid=150080 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:27:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:57:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 16:57:17', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:27:17";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:57:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:57:17', '2', 'editprint', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150080');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:27:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:57:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:57:22', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:27:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:57:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:57:36', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e2d268296
-- ----------------------------------------------------------------------------------------------------

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-18 16:57:22', '06762e2d268296', '1', '0.00', '0', '0', '1', '580.00', '580', '580', '0', '1', '2024-12-18 16:57:36', '', '104', '0', 'نقدي', '1', '0', '3', '99', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','580','0','','0','0','580','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150081', '0', '2024-12-18 16:57:36', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '580', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:57:22','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35910;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150081', '5', '16297', '1', '580', '580', '0', '', '1', '2024-12-18 16:57:36', '16297', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35910-1,','1','1','0','0','580','580','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 = 548342;
 INSERT INTO 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-18', 580, 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+580, 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-18', 580, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0, 510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, 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 = '95', userid = '104', storedetaildate = '2024-12-18 16:57:36' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '1', '150081', 'اضافة فاتورة مبيعات', 'sellbillController.php', '96', '95', '104', '2024-12-18 16:57:36','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '31265',  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 ('30685','580', '0', '1', 'اضافة فاتورة مبيعات', '150081', '31265', '2024-12-18 16:57:36', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 99 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-18', 580, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, 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 (1, '2024-12-18', 580, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, 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, 580, 510, 510
                    , 510, 510, 510, 510, 510, 510)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+580, 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 add end - with serial 06762e2d268296 and sellbillId = 150081 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e2e159824
-- ----------------------------------------------------------------------------------------------------

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-18 16:57:37', '06762e2e159824', '1', '0.00', '0', '0', '1', '400.00', '400', '400', '0', '1', '2024-12-18 16:58:15', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150082', '0', '2024-12-18 16:58:15', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '400', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 16:57:37','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', '150082', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-18 16:58:15', '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 = 305, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 548343;
 INSERT INTO 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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 305, 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+305
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 305, 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+305
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '104', storedetaildate = '2024-12-18 16:58:15' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150082', 'اضافة فاتورة مبيعات', 'sellbillController.php', '35', '34', '104', '2024-12-18 16:58:15','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '31665',  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 ('31265','400', '0', '1', 'اضافة فاتورة مبيعات', '150082', '31665', '2024-12-18 16:58:15', '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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 305, 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+305
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 305, 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+305
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 305)
                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+305;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e2e159824 and sellbillId = 150082 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:28:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 16:58:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:58:16', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:28:36";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:58:36", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:58:36', '2', '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-18 13:29:32";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:59:32", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:59:32', '2', 'addAndRetuen', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e31ca1312
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9016,@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-18 16:58:36', '06762e31ca1312', '9016', '960.00', '1293', '0', '1', '333.00', '333', '0', '333', '1', '2024-12-18 16:59:32', '', '2', '0', 'لميس فرج P504', '2', '1', '3', '82', 'لميس فرج P504', '2' ,'0','','','','','-1','0','0','0','0','0','333','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1293', userid = '2' WHERE clientid = '9016';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9016','960.00','333','0','اضافة فاتورة مبيعات','150083', '1293', '2024-12-18 16:59:32', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات', '333', '0', null, '0', null, null,'', '0','1','1','333','1','2024-12-18 16:58:36','0','0');
UPDATE client SET  inUse = 0 where clientid = 9016;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35504;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0K800', '150083', '7', '16097', '1', '330', '330', '0', '', '1', '2024-12-18 16:59:32', '16097', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35504-1,','1','1','0','0','330','330','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 = 548344;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16097, '2024-12-18', 330, 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+330, 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-18', 330, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, 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 = '4', userid = '2', storedetaildate = '2024-12-18 16:59:32' WHERE storedetailid = '16096';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16097', '1', '1', '1', '150083', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '2', '2024-12-18 16:59: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 ('0','10291', '150083', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-18 16:59:32', '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 = 82 where clientid = 9016;
 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-18', 333, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+333, 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 (9016, '2024-12-18', 333, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+333, 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, 333, 240, 240
                    , 240, 240, 240, 240, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+333, 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 06762e31ca1312 and sellbillId = 150083 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:29:33";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 16:59:33", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 16:59:33', '2', '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-18 13:30:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:00:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:00:40', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:30:49";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:00:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:00:49', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247375
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7978,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-2' , clientdate = '2024-12-18 17:00:50', userid = '2' WHERE clientid = '7978';
UPDATE client SET  inUse = 0 where clientid = 7978;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7978','1818.00','1820','1','ايصال تحصيل (( قبض من عميل ))','247375', '-2', '2024-12-18 16:25:04', '2', 'clientPayedDeptController.php', '   ', '1820', '0', null, '0', null, null,'', '-1','1','1','1820','1','','3520','0');
UPDATE save SET  savecurrentvalue = '224106.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('222286.50','1820', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247405', '224106.5', '2024-12-18 17:00:50', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1820', '1820', '2024-12-18', '2', '0', '0', '2024-12-18 17:00:50','اضافة ايصال سداد للعميل يمني يحيي b14','1','0','0','0','247405','clientPayedDeptController.php?do=show&id=247405');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122168', '-1', '1820', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1820', 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 ('122168', '-1', '1820', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1820', 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 = '7978', clientdebtchangebefore = '1818.000', clientdebtchangeamount = '1820.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247375', clientdebtchangeafter = '-2.000', clientdebtchangedate = '2024-12-18 16:25:04', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1820.00',discount='', reciptid='0', dailyentryid = '122168',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1820',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247405';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247375 -clientdebtchangeId = 247405
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:30:50";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:00:50", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:00: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-18 13:31:26";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:01:26", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:01:26', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247406
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5780,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 17:01:26', userid = '2' WHERE clientid = '5780';
UPDATE client SET  inUse = 0 where clientid = 5780;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5780','10342.00','10342','1','ايصال تحصيل (( قبض من عميل ))','247406', '0', '2024-12-18 17:00:51', '2', 'clientPayedDeptController.php', '   ', '10342', '0', null, '0', null, null,'', '-1','1','1','10342','1','','3521','0');
UPDATE save SET  savecurrentvalue = '234448.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('224106.50','10342', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247406', '234448.5', '2024-12-18 17:01:26', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '10342', '10342', '2024-12-18', '2', '0', '0', '2024-12-18 17:01:26','اضافة ايصال سداد للعميل اية حسين كفر الدوار 58','1','0','0','0','247406','clientPayedDeptController.php?do=show&id=247406');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122169', '-1', '10342', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '10342', 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 ('122169', '-1', '10342', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-10342', 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 = '5780', clientdebtchangebefore = '10342.000', clientdebtchangeamount = '10342.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247406', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 17:00:51', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '10342.00',discount='', reciptid='0', dailyentryid = '122169',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='10342',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247406';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247407
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(804,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '20' , clientdate = '2024-12-18 17:01:47', userid = '2' WHERE clientid = '804';
UPDATE client SET  inUse = 0 where clientid = 804;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('804','939.00','919','1','ايصال تحصيل (( قبض من عميل ))','247407', '20', '2024-12-18 17:01:27', '2', 'clientPayedDeptController.php', '   ', '919', '0', null, '0', null, null,'', '-1','1','1','919','1','','3522','0');
UPDATE save SET  savecurrentvalue = '235367.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('234448.50','919', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247407', '235367.5', '2024-12-18 17:01:47', '2',  'clientPayedDeptController.php','0','','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:31:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:01:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:01:47', '104', 'addsellBill', '192.168.1.13', '', '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 ( '919', '919', '2024-12-18', '2', '0', '0', '2024-12-18 17:01:47','اضافة ايصال سداد للعميل نفين الدمرداش K101','1','0','0','0','247407','clientPayedDeptController.php?do=show&id=247407');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122170', '-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 ('122170', '-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 = '804', clientdebtchangebefore = '939.000', clientdebtchangeamount = '919.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247407', clientdebtchangeafter = '20.000', clientdebtchangedate = '2024-12-18 17:01:27', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '919.00',discount='', reciptid='0', dailyentryid = '122170',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='919',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247407';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247408
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6971,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '296' , clientdate = '2024-12-18 17:02:17', userid = '2' WHERE clientid = '6971';
UPDATE client SET  inUse = 0 where clientid = 6971;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6971','671.00','375','1','ايصال تحصيل (( قبض من عميل ))','247408', '296', '2024-12-18 17:01:48', '2', 'clientPayedDeptController.php', '   ', '375', '0', null, '0', null, null,'', '-1','1','1','375','1','','3523','0');
UPDATE save SET  savecurrentvalue = '235742.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('235367.50','375', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247408', '235742.5', '2024-12-18 17:02:17', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '375', '375', '2024-12-18', '2', '0', '0', '2024-12-18 17:02:17','اضافة ايصال سداد للعميل جهاد عبدالعزيز X65','1','0','0','0','247408','clientPayedDeptController.php?do=show&id=247408');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122171', '-1', '375', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '375', 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 ('122171', '-1', '375', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-375', 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 = '6971', clientdebtchangebefore = '671.000', clientdebtchangeamount = '375.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247408', clientdebtchangeafter = '296.000', clientdebtchangedate = '2024-12-18 17:01:48', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '375.00',discount='', reciptid='0', dailyentryid = '122171',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='375',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247408';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:32:17";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:02:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:02: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-18 13:32:36";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:02:36", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:02:36', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247409
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7950,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 17:02:36', userid = '2' WHERE clientid = '7950';
UPDATE client SET  inUse = 0 where clientid = 7950;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7950','1929.00','1929','1','ايصال تحصيل (( قبض من عميل ))','247409', '0', '2024-12-18 17:02:18', '2', 'clientPayedDeptController.php', '   ', '1929', '0', null, '0', null, null,'', '-1','1','1','1929','1','','3524','0');
UPDATE save SET  savecurrentvalue = '237671.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('235742.50','1929', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247409', '237671.5', '2024-12-18 17:02:36', '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 ('اسماء احمد W227', 'اسماء احمد W227', 'اسماء احمد W227', 'اسماء احمد W227', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-18 17:02:36');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1929', '1929', '2024-12-18', '2', '0', '0', '2024-12-18 17:02:36','اضافة ايصال سداد للعميل اسماء احمد W227','1','0','0','0','247409','clientPayedDeptController.php?do=show&id=247409');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122172', '-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 ('122172', '12557', '1929', '','0');
UPDATE accountstree SET name = 'اسماء احمد W227', customName = 'اسماء احمد W227', customNameEn = 'اسماء احمد W227', nameEn = 'اسماء احمد W227', parent = '58', accountNature = '0', theValue = '-1929', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 17:02:36' WHERE id = '12557';
UPDATE clientdebtchange SET clientid = '7950', clientdebtchangebefore = '1929.000', clientdebtchangeamount = '1929.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247409', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 17:02:18', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1929.00',discount='', reciptid='0', dailyentryid = '122172',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1929',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247409';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:32:37";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:02:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:02: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-18 13:32:54";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:02:54", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:02:54', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247410
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6868,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 17:02:54', userid = '2' WHERE clientid = '6868';
UPDATE client SET  inUse = 0 where clientid = 6868;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6868','737.00','737','1','ايصال تحصيل (( قبض من عميل ))','247410', '0', '2024-12-18 17:02:37', '2', 'clientPayedDeptController.php', '   ', '737', '0', null, '0', null, null,'', '-1','1','1','737','1','','3525','0');
UPDATE save SET  savecurrentvalue = '238408.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('237671.50','737', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247410', '238408.5', '2024-12-18 17:02:54', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '737', '737', '2024-12-18', '2', '0', '0', '2024-12-18 17:02:54','اضافة ايصال سداد للعميل اسراء فؤاد E211','1','0','0','0','247410','clientPayedDeptController.php?do=show&id=247410');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122173', '-1', '737', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '737', 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 ('122173', '-1', '737', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-737', 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 = '6868', clientdebtchangebefore = '737.000', clientdebtchangeamount = '737.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247410', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 17:02:37', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '737.00',discount='', reciptid='0', dailyentryid = '122173',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='737',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247410';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:32:55";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:02:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:02: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-18 13:33:29";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:03:29", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:03:29', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247411
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9085,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '25' , clientdate = '2024-12-18 17:03:29', userid = '2' WHERE clientid = '9085';
UPDATE client SET  inUse = 0 where clientid = 9085;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9085','970.00','945','1','ايصال تحصيل (( قبض من عميل ))','247411', '25', '2024-12-18 17:02:55', '2', 'clientPayedDeptController.php', '   ', '945', '0', null, '0', null, null,'', '-1','1','1','945','1','','3526','0');
UPDATE save SET  savecurrentvalue = '239353.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('238408.50','945', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247411', '239353.5', '2024-12-18 17:03:29', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '945', '945', '2024-12-18', '2', '0', '0', '2024-12-18 17:03:29','اضافة ايصال سداد للعميل هبة رضا m222','1','0','0','0','247411','clientPayedDeptController.php?do=show&id=247411');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122174', '-1', '945', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '945', 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 ('122174', '-1', '945', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-945', 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 = '9085', clientdebtchangebefore = '970.000', clientdebtchangeamount = '945.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247411', clientdebtchangeafter = '25.000', clientdebtchangedate = '2024-12-18 17:02:55', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '945.00',discount='', reciptid='0', dailyentryid = '122174',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='945',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247411';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247412
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8825,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 17:04:14', userid = '2' WHERE clientid = '8825';
UPDATE client SET  inUse = 0 where clientid = 8825;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8825','2071.00','2071','1','ايصال تحصيل (( قبض من عميل ))','247412', '0', '2024-12-18 17:03:30', '2', 'clientPayedDeptController.php', '   ', '2071', '0', null, '0', null, null,'', '-1','1','1','2071','1','','3527','0');
UPDATE save SET  savecurrentvalue = '241424.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('239353.50','2071', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247412', '241424.5', '2024-12-18 17:04:14', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '2071', '2071', '2024-12-18', '2', '0', '0', '2024-12-18 17:04:14','اضافة ايصال سداد للعميل ياسمين حجاج k21','1','0','0','0','247412','clientPayedDeptController.php?do=show&id=247412');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122175', '-1', '2071', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '2071', 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 ('122175', '-1', '2071', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-2071', 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 = '8825', clientdebtchangebefore = '2071.000', clientdebtchangeamount = '2071.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247412', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 17:03:30', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '2071.00',discount='', reciptid='0', dailyentryid = '122175',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='2071',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247412';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:34:15";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:04:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:04:15', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:34:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:04:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 17:04:21', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:34:36";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:04:36", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:04:36', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247413
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8799,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '179' , clientdate = '2024-12-18 17:04:36', userid = '2' WHERE clientid = '8799';
UPDATE client SET  inUse = 0 where clientid = 8799;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8799','1879.00','1700','1','ايصال تحصيل (( قبض من عميل ))','247413', '179', '2024-12-18 17:04:15', '2', 'clientPayedDeptController.php', '   ', '1700', '0', null, '0', null, null,'', '-1','1','1','1700','1','','3528','0');
UPDATE save SET  savecurrentvalue = '243124.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('241424.50','1700', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247413', '243124.5', '2024-12-18 17:04:36', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1700', '1700', '2024-12-18', '2', '0', '0', '2024-12-18 17:04:36','اضافة ايصال سداد للعميل دلال فوزي','1','0','0','0','247413','clientPayedDeptController.php?do=show&id=247413');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122176', '-1', '1700', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1700', 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 ('122176', '-1', '1700', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1700', 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 = '8799', clientdebtchangebefore = '1879.000', clientdebtchangeamount = '1700.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247413', clientdebtchangeafter = '179.000', clientdebtchangedate = '2024-12-18 17:04:15', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1700.00',discount='', reciptid='0', dailyentryid = '122176',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1700',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247413';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:34:37";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:04:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:04: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-18 13:34:58";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:04:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:04:58', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247414
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6822,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 17:04:58', userid = '2' WHERE clientid = '6822';
UPDATE client SET  inUse = 0 where clientid = 6822;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6822','434.00','434','1','ايصال تحصيل (( قبض من عميل ))','247414', '0', '2024-12-18 17:04:37', '2', 'clientPayedDeptController.php', '   ', '434', '0', null, '0', null, null,'', '-1','1','1','434','1','','3529','0');
UPDATE save SET  savecurrentvalue = '243558.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('243124.50','434', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247414', '243558.5', '2024-12-18 17:04:58', '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 ('هند السعيد K553', 'هند السعيد K553', 'هند السعيد K553', 'هند السعيد K553', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-18 17:04:58');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '434', '434', '2024-12-18', '2', '0', '0', '2024-12-18 17:04:58','اضافة ايصال سداد للعميل هند السعيد K553','1','0','0','0','247414','clientPayedDeptController.php?do=show&id=247414');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122177', '-1', '434', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '434', 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 ('122177', '12558', '434', '','0');
UPDATE accountstree SET name = 'هند السعيد K553', customName = 'هند السعيد K553', customNameEn = 'هند السعيد K553', nameEn = 'هند السعيد K553', parent = '58', accountNature = '0', theValue = '-434', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 17:04:58' WHERE id = '12558';
UPDATE clientdebtchange SET clientid = '6822', clientdebtchangebefore = '434.000', clientdebtchangeamount = '434.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247414', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 17:04:37', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '434.00',discount='', reciptid='0', dailyentryid = '122177',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='434',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247414';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:34:59";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:04:59", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:04: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-18 13:35:06";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:05:06", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:05:06', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e0d0736b1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7243,@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-18 16:48:48', '06762e0d0736b1', '7243', '74.00', '5438', '0', '1', '5364.00', '5364', '0', '5364', '1', '2024-12-18 17:05:06', '', '75', '0', 'مريم سعيد اسوان y166', '2', '1', '3', '80', 'مريم سعيد اسوان y166', '19' ,'0','','','','','-1','0','0','0','0','0','5364','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '5438', userid = '75' WHERE clientid = '7243';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7243','74.00','5364','0','اضافة فاتورة مبيعات','150084', '5438', '2024-12-18 17:05:06', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '5364', '0', null, '0', null, null,'', '0','1','1','5364','1','2024-12-18 16:48:48','0','0');
UPDATE client SET  inUse = 0 where clientid = 7243;
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', '150084', '14', '16340', '1', '500', '500', '0', '', '1', '2024-12-18 17:05:06', '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 = 548346;
 INSERT INTO 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-18', 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-18', 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 = '10', userid = '75', storedetaildate = '2024-12-18 17:05:06' WHERE storedetailid = '16339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16340', '1', '1', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-18 17:05:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35903;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07237', '150084', '5', '16295', '1', '260', '260', '0', '', '1', '2024-12-18 17:05:06', '16295', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35903-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 = 548347;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16295, '2024-12-18', 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-18', 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 = '4', userid = '75', storedetaildate = '2024-12-18 17:05:06' WHERE storedetailid = '16294';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16295', '1', '1', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 17:05:06','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', '150084', '5', '15654', '1', '360', '360', '0', '', '1', '2024-12-18 17:05:06', '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 = 548348;
 INSERT INTO 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-18', 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-18', 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 = '12', userid = '75', storedetaildate = '2024-12-18 17:05:06' WHERE storedetailid = '15653';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15654', '1', '1', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-18 17:05:06','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', '150084', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-18 17:05:06', '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 = 305, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 548349;
 INSERT INTO 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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 305, 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+305
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 305, 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+305
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '75', storedetaildate = '2024-12-18 17:05:06' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '34', '33', '75', '2024-12-18 17:05:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35505;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0K801', '150084', '7', '16098', '1', '220', '220', '0', '', '1', '2024-12-18 17:05:06', '16098', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35505-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 = 548350;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16098, '2024-12-18', 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-18', 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 = '3', userid = '75', storedetaildate = '2024-12-18 17:05:06' WHERE storedetailid = '16097';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16098', '1', '1', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-18 17:05:06','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', '150084', '5', '16254', '1', '650', '650', '0', '', '1', '2024-12-18 17:05:06', '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 = 548351;
 INSERT INTO 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-18', 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-18', 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 = '13', userid = '75', storedetaildate = '2024-12-18 17:05:06' WHERE storedetailid = '16253';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16254', '1', '1', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-18 17:05:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36057;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150084', '5', '16347', '1', '200', '200', '0', '', '1', '2024-12-18 17:05:06', '16347', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36057-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 = 548352;
 INSERT INTO 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-18', 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-18', 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 = '13', userid = '75', storedetaildate = '2024-12-18 17:05:06' WHERE storedetailid = '16346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16347', '1', '1', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-18 17:05:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150084', '5', '16278', '2', '200', '400', '0', '', '1', '2024-12-18 17:05:06', '16278', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36120-2,','1','1','0','0','200','400','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 = 548353;
 INSERT INTO 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-18', 400, 310, 310
                    , 296, 310, 296, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 310, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+296
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+296
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , 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-18', 400, 310, 310
                    , 296, 310, 296, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+296
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+296
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , 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 = '22', userid = '75', storedetaildate = '2024-12-18 17:05:06' WHERE storedetailid = '16277';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16278', '1', '2', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '22', '75', '2024-12-18 17:05: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 ('210','H1585', '150084', '14', '16163', '1', '280', '280', '0', '', '1', '2024-12-18 17:05:06', '16163', '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 = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where sellbilldetailid = 548354;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16163, '2024-12-18', 280, 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+280, 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-18', 280, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, 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 = '0', userid = '75', storedetaildate = '2024-12-18 17:05:06' WHERE storedetailid = '16162';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16163', '1', '1', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-18 17:05:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33829;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3125', '150084', '1', '15097', '1', '70', '70', '0', '', '1', '2024-12-18 17:05:06', '15097', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33829-1,','1','1','0','0','70','70','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 = 548355;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15097, '2024-12-18', 70, 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+70, 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-18', 70, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+70, 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 = '7', userid = '75', storedetaildate = '2024-12-18 17:05:06' WHERE storedetailid = '15096';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15097', '1', '1', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-18 17:05:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35831;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07177', '150084', '5', '16245', '1', '300', '300', '0', '', '1', '2024-12-18 17:05:06', '16245', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35831-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
                where sellbilldetailid = 548356;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16245, '2024-12-18', 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-18', 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 = '4', userid = '75', storedetaildate = '2024-12-18 17:05:06' WHERE storedetailid = '16244';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16245', '1', '1', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 17:05:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36429;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07307', '150084', '5', '16457', '1', '300', '300', '0', '', '1', '2024-12-18 17:05:06', '16457', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36429-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 = 548357;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16457, '2024-12-18', 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-18', 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 = '13', userid = '75', storedetaildate = '2024-12-18 17:05:06' WHERE storedetailid = '16456';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16457', '1', '1', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-18 17:05:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35476;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('580','H1495', '150084', '14', '15933', '1', '700', '700', '0', '', '1', '2024-12-18 17:05:06', '15933', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35476-1,','1','1','0','0','700','700','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 580.00 , meanbuyprice = 580.00, lastbuyprice_withDiscount = 580.00, meanbuyprice_withDiscount = 580.00
        , lastbuyprice_withTax = 580, meanbuyprice_withTax = 580, lastbuyprice_withDiscountAndTax = 580
                where sellbilldetailid = 548358;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15933, '2024-12-18', 700, 580, 580
                    , 580, 580, 580, 580
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 580, 580, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+580
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+580
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+580
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+580
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 700, 580, 580
                    , 580, 580, 580, 580
                    , 0, 0, 0, 0
                    , 0, 0, 0, 580, 580, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+700, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+580
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+580
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+580
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+580
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 17:05:06' WHERE storedetailid = '15932';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15933', '1', '1', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 17:05: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 ('210','0H786', '150084', '14', '8738', '2', '205', '410', '0', '', '1', '2024-12-18 17:05:06', '8738', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','205','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 209.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 209.00
        
                where sellbilldetailid = 548359;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8738, '2024-12-18', 410, 420, 420
                    , 418, 420, 418, 412.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+418
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+418
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+412.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+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-18', 410, 420, 420
                    , 418, 420, 418, 412.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+420, sellCostMeanBuyPrice = sellCostMeanBuyPrice+418
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+420, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+418
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+412.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-18 17:05:06' WHERE storedetailid = '8737';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('8738', '1', '2', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '0', '75', '2024-12-18 17:05:06','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', '150084', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-18 17:05:06', '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 = 548360;
 INSERT INTO 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-18', 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-18', 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 = '48', userid = '75', storedetaildate = '2024-12-18 17:05:06' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '1', '150084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '49', '48', '75', '2024-12-18 17:05: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', '150084', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 17:05: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', '150084', '17', '10291', '1', '54', '54', '0', '', '1', '2024-12-18 17:05:07', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','54','54','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 80 where clientid = 7243;
 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-18', 5364, 4490, 4490
                    , 4532, 4490, 4532, 4482.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3830, 3611, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+5364, sellCostBuyPrice =sellCostBuyPrice+4490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4490, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4532
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4490, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4532
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+4482.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3830
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3611
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (7243, '2024-12-18', 5364, 4490, 4490
                    , 4532, 4490, 4532, 4482.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3830, 3611, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+5364, sellCostBuyPrice =sellCostBuyPrice+4490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4490, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4532
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4490, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4532
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+4482.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3830
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3611
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 5364, 4490, 4490
                    , 4532, 4490, 4532, 4482.5, 3830, 3611)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+5364, netSellCostBuyPrice = netSellCostBuyPrice+4490
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+4490
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+4532
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+4490
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+4532
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+4482.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+3830
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+3611;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e0d0736b1 and sellbillId = 150084 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:35:07";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:05:07", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:05:07', '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-18 13:35:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:05:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 17:05:26', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=add');
BEGIN;
CALL supplierInUse(49,@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 ('49', '26320.00', '2000', '1', 'ايصال دفع لمورد', '1', '24320', '2024-12-18 17:04:21', '104', 'supplierPayedDeptController.php', '', '0','1', '-1','1','1','2000','1','0','0','0','405');
UPDATE supplierdebtchange SET supplierid = '49', supplierdebtchangebefore = '26320.00', supplierdebtchangeamount = '2000', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '24320', supplierdebtchangedate = '2024-12-18 17:04:21', userid = '104', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='2000',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='26320',debtchangamountInSupplierCurrency='24320',debtchangafterInSupplierCurrency='24320', paySerialNo='405' WHERE supplierdebtchangeid = '26809';
UPDATE supplier SET  suppliercurrentDebt = '24320',suppliercurrentDebtInCurrency= '24320' , userid = '104', supplierdate = '2024-12-18 17:05:26'   WHERE supplierid = '49';
UPDATE supplier SET  inUse = 0 where supplierid = 49;
UPDATE save SET  savecurrentvalue = '29665',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('31665.00','2000', '1', '1', 'ايصال دفع لمورد', '26809', '29665', '2024-12-18 17:05:26', '104',  'supplierPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '2000', '2000', '2024-12-18', '104', '0', '0', '2024-12-18 17:05:26','ايصال دفع لمورد ( مصنع دريم ) ','1','0','-1','0','26809','supplierReportsController.php?do=show&id=26809');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122178', '-1', '2000', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '2000', 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 ('122178', '-1', '2000', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-2000', 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 = '49', supplierdebtchangebefore = '26320.00', supplierdebtchangeamount = '2000.00', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '24320.00', supplierdebtchangedate = '2024-12-18 17:04:21', userid = '104', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '122178',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='2000',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='26320',debtchangamountInSupplierCurrency='24320',debtchangafterInSupplierCurrency='24320', paySerialNo='405' WHERE supplierdebtchangeid = '26809';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:35:27";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:05:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 17:05:27', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:35:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:05:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 17:05:28', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:35:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:05:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 17:05:29', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:35:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:05:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:05:47', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:35:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:05:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:05:54', '104', 'add', '192.168.1.13', '', '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-18', '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 = '29645',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('29665.00','20', '1', '1', 'إضافة مصروف', '25824', '29645', '2024-12-18 17:05:54', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'مشال', expensesdetails = '', expensesValue = '20.00', expensesdate = '2024-12-18', 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 = '25824';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:35:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:05:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:05:54', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:35:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:05:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:05:56', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:37:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:07:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:07:17', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:37:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:07:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:07:29', '104', 'add', '192.168.1.13', '', '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-18', '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 = '29595',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('29645.00','50', '1', '1', 'إضافة مصروف', '25825', '29595', '2024-12-18 17:07:29', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'محمد عبدة', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-18', 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 = '25825';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:37:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:07:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:07:29', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:37:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:07:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:07:31', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:39:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:09:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:09:45', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e3db54a86
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4706,@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-18 17:01:47', '06762e3db54a86', '4706', '0.00', '1858', '0', '1', '1858.00', '1858', '0', '1858', '1', '2024-12-18 17:09:46', '', '104', '0', 'تامر عبدالحميد F88', '1', '1', '3', '26', 'تامر عبدالحميد F88', '6' ,'0','','','','','-1','0','0','0','0','0','1858','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1858', userid = '104' WHERE clientid = '4706';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4706','0.00','1858','0','اضافة فاتورة مبيعات','150085', '1858', '2024-12-18 17:09:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1858', '0', null, '0', null, null,'', '0','1','1','1858','1','2024-12-18 17:01:47','0','0');
UPDATE client SET  inUse = 0 where clientid = 4706;
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', '150085', '14', '16372', '1', '410', '410', '0', '', '1', '2024-12-18 17:09:46', '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 = 548363;
 INSERT INTO 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-18', 410, 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+410, 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-18', 410, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, 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 = '13', userid = '104', storedetaildate = '2024-12-18 17:09:46' WHERE storedetailid = '16371';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16372', '1', '1', '1', '150085', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '104', '2024-12-18 17:09:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33718;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3160', '150085', '1', '15212', '1', '310', '310', '0', '', '1', '2024-12-18 17:09:46', '15212', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33718-1,','1','1','0','0','310','310','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 = 548364;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15212, '2024-12-18', 310, 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+310, 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-18', 310, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, 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 = '1', userid = '104', storedetaildate = '2024-12-18 17:09:46' WHERE storedetailid = '15211';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15212', '1', '1', '1', '150085', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-18 17:09:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36245;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150085', '14', '16409', '1', '290', '290', '0', '', '1', '2024-12-18 17:09:46', '16409', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36245-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 = 548365;
 INSERT INTO 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-18', 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-18', 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 = '5', userid = '104', storedetaildate = '2024-12-18 17:09:46' WHERE storedetailid = '16408';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16409', '1', '1', '1', '150085', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-18 17:09:46','0','0');
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', '150085', '14', '16406', '1', '450', '450', '0', '', '1', '2024-12-18 17:09:46', '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 = 548366;
 INSERT INTO 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-18', 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-18', 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 = '23', userid = '104', storedetaildate = '2024-12-18 17:09:46' WHERE storedetailid = '16405';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16406', '1', '1', '1', '150085', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '104', '2024-12-18 17:09:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35959;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3272', '150085', '1', '15763', '1', '380', '380', '0', '', '1', '2024-12-18 17:09:46', '15763', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35959-1,','1','1','0','0','380','380','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 = 548367;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15763, '2024-12-18', 380, 340, 340
                    , 340, 340, 340, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , 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-18', 380, 340, 340
                    , 340, 340, 340, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 340, 340, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+335
                            , 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 = '11', userid = '104', storedetaildate = '2024-12-18 17:09:46' WHERE storedetailid = '15762';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15763', '1', '1', '1', '150085', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-18 17:09: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', '150085', '17', '10291', '1', '18', '18', '0', '', '1', '2024-12-18 17:09:46', '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 = 26 where clientid = 4706;
 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-18', 1858, 1535, 1535
                    , 1535, 1535, 1535, 1530
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1265, 1265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1858, sellCostBuyPrice =sellCostBuyPrice+1535
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1535, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1535
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1535
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1530
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (4706, '2024-12-18', 1858, 1535, 1535
                    , 1535, 1535, 1535, 1530
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1265, 1265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1858, sellCostBuyPrice =sellCostBuyPrice+1535
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1535, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1535
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1535
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1530
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1265
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1858, 1535, 1535
                    , 1535, 1535, 1535, 1530, 1265, 1265)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1858, netSellCostBuyPrice = netSellCostBuyPrice+1535
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1535
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1535
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1535
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1535
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1530
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1265
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1265;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e3db54a86 and sellbillId = 150085 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:39:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:09:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:09:47', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:40:21";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:10:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:10:21', '2', 'addAndRetuen', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e35578b72
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9689,@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-18 16:59:33', '06762e35578b72', '9689', '0.00', '475', '0', '1', '475.00', '475', '0', '475', '1', '2024-12-18 17:10:21', '', '2', '0', 'شروق خالد 26', '2', '1', '3', '82', 'شروق خالد 26', '4' ,'0','','','','','-1','0','0','0','0','0','475','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '475', userid = '2' WHERE clientid = '9689';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9689','0.00','475','0','اضافة فاتورة مبيعات','150086', '475', '2024-12-18 17:10:21', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات', '475', '0', null, '0', null, null,'', '0','1','1','475','1','2024-12-18 16:59:33','0','0');
UPDATE client SET  inUse = 0 where clientid = 9689;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36005;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150086', '5', '15855', '1', '210', '210', '0', '', '1', '2024-12-18 17:10:21', '15855', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36005-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 = 548369;
 INSERT INTO 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-18', 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-18', 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 = '24', userid = '2', storedetaildate = '2024-12-18 17:10:21' WHERE storedetailid = '15854';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15855', '1', '1', '1', '150086', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '2', '2024-12-18 17:10:21','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', '150086', '5', '16152', '1', '240', '240', '0', '', '1', '2024-12-18 17:10:21', '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 = 548370;
 INSERT INTO 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-18', 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-18', 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 = '26', userid = '2', storedetaildate = '2024-12-18 17:10:21' WHERE storedetailid = '16151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16152', '1', '1', '1', '150086', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27', '26', '2', '2024-12-18 17:10: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', '150086', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 17:10:21', '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', '150086', '17', '10291', '1', '5', '5', '0', '', '1', '2024-12-18 17:10:21', '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 = 82 where clientid = 9689;
 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-18', 475, 345, 345
                    , 345, 345, 345, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,345, 345, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+475, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+345
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+345
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (9689, '2024-12-18', 475, 345, 345
                    , 345, 345, 345, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,345, 345, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+475, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+345
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+345
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 475, 345, 345
                    , 345, 345, 345, 345, 345, 345)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+475, netSellCostBuyPrice = netSellCostBuyPrice+345
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+345
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+345
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+345
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+345
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+345
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+345
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+345;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e35578b72 and sellbillId = 150086 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:40:21";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:10:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:10:22', '2', '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-18 13:41:16";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:11:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:11:16', '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-18 13:41:28";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:11:28", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:11: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-18 13:41:40";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:11:40", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:11:40', '2', 'editsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150021');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:41:49";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:11:49", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:11:49', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e4a3b65a7
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7145,@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-18 17:05:07', '06762e4a3b65a7', '7145', '-345.00', '-199', '0', '1', '146.00', '146', '0', '146', '1', '2024-12-18 17:11:49', '', '75', '0', 'اية سيد علي Y120', '2', '1', '3', '80', 'اية سيد علي Y120', '2' ,'0','','','','','-1','0','0','0','0','0','146','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '-199', userid = '75' WHERE clientid = '7145';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7145','-345.00','146','0','اضافة فاتورة مبيعات','150087', '-199', '2024-12-18 17:11:49', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '146', '0', null, '0', null, null,'', '0','1','1','146','1','2024-12-18 17:05:07','0','0');
UPDATE client SET  inUse = 0 where clientid = 7145;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31799;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0K734', '150087', '7', '14288', '1', '145', '145', '0', '', '1', '2024-12-18 17:11:49', '14288', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31799-1,','1','1','0','0','145','145','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 = 548373;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14288, '2024-12-18', 145, 150, 150
                    , 150, 150, 150, 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+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , 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-18', 145, 150, 150
                    , 150, 150, 150, 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+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , 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 = '1', userid = '75', storedetaildate = '2024-12-18 17:11:49' WHERE storedetailid = '14287';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14288', '1', '1', '1', '150087', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-18 17:11: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 ('0','10291', '150087', '17', '10291', '1', '1', '1', '0', '', '1', '2024-12-18 17:11:49', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','1','1','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 80 where clientid = 7145;
 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-18', 146, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+146, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7145, '2024-12-18', 146, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+146, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 146, 150, 150
                    , 150, 150, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+146, netSellCostBuyPrice = netSellCostBuyPrice+150
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+150
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+150
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+150
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+150
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+150
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e4a3b65a7 and sellbillId = 150087 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:41:50";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:11:50", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:11: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-18 13:42:05";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:12:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:12:05', '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 = 150021 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


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

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150021;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 17:12:06', userid = '75',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '150021';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36085;
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 = 548015;
 INSERT INTO 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-18', 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-18', 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 = '10', userid = '2', storedetaildate = '2024-12-18 17:12:06' WHERE storedetailid = '16364';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16365', '1', '1', '0', '150021', 'تعديل فاتورة مبيعات', 'sellbillController.php', '9', '10', '2', '2024-12-18 14:21:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36182;
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 = 548016;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16052, '2024-12-18', 400, 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-400, 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-18', 400, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-400, 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 = '18', userid = '2', storedetaildate = '2024-12-18 17:12:06' WHERE storedetailid = '16051';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16052', '1', '1', '0', '150021', 'تعديل فاتورة مبيعات', 'sellbillController.php', '17', '18', '2', '2024-12-18 14:21:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 36115;
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 = 548017;
 INSERT INTO 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-18', 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-18', 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 = '41', userid = '2', storedetaildate = '2024-12-18 17:12:06' WHERE storedetailid = '16274';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16275', '1', '1', '0', '150021', 'تعديل فاتورة مبيعات', 'sellbillController.php', '40', '41', '2', '2024-12-18 14:21:15','0','0');
CALL clientInUse(8406,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '2' WHERE clientid = '8406';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8406','1374.00','1374.00','1','تعديل فاتورة مبيعات','150021', '0', '2024-12-18 14:21:15', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '1374', '0', null, '0', null, null,'', '0','1','1','1374','1','2024-12-18 14:21:15','0','0');
UPDATE client SET  inUse = 0 where clientid = 8406;
 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-18', 1374, 1155, 1155
                    , 1156, 1155, 1156, 1155
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1155, 1156, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1374, sellCostBuyPrice =sellCostBuyPrice-1155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1155, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1156
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1156
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1156
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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 (8406, '2024-12-18', 1374, 1155, 1155
                    , 1156, 1155, 1156, 1155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1155, 1156, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1374, sellCostBuyPrice =sellCostBuyPrice-1155
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1155, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1156
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1155, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1156
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1155
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1155
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-1156
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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, 1374, 1155, 1155
                    , 1156, 1155, 1156, 1155, 1155, 1156)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-1374, netSellCostBuyPrice = netSellCostBuyPrice-1155
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-1155
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-1156
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-1155
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-1156
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-1155
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-1155
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-1156;

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


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

COMMIT;
BEGIN;
CALL clientInUse(8406,@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 14:21:15', '06762be3b7c4f6', '8406', '0.00', '1040', '0', '1', '1040', '1040', '0', '1040', '1', '2024-12-18 14:21:15', '', '2', '0', 'مي احمد طنطا W351', '2', '1', '3', '83', 'مي احمد طنطا W351', '4', '150021', '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 = '1040', userid = '2' WHERE clientid = '8406';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8406','0.00','1040','0','اضافة فاتورة مبيعات (معدله)','150088', '1040', '2024-12-18 17:12:06', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '1040', '0', null, '0', null, null,'', '0','1','1','1374','1','2024-12-18 14:21:15','0','0');
UPDATE client SET  inUse = 0 where clientid = 8406;
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', '150088', '1', '16365', '1', '610', '610', '0', '', '1', '2024-12-18 17:12:06', '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 = 548375;
 INSERT INTO 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-18', 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-18', 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 = '9', userid = '2', storedetaildate = '2024-12-18 17:12:06' WHERE storedetailid = '16364';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16365', '1', '1', '1', '150088', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '10', '9', '2', '2024-12-18 17:12:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36182;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07074', '150088', '5', '16052', '1', '400', '400', '0', '', '1', '2024-12-18 17:12:06', '16052', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36182-1,','1','1','0','0','400','400','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 = 548376;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16052, '2024-12-18', 400, 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+400, 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-18', 400, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, 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 = '17', userid = '2', storedetaildate = '2024-12-18 17:12:06' WHERE storedetailid = '16051';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16052', '1', '1', '1', '150088', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '18', '17', '2', '2024-12-18 17:12: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', '150088', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 17:12: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', '150088', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-18 17:12:06', '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-18', 1040, 875, 875
                    , 875, 875, 875, 875
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,875, 875, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1040, sellCostBuyPrice =sellCostBuyPrice+875
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+875, sellCostMeanBuyPrice = sellCostMeanBuyPrice+875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+875, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+875
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+875
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+875
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (8406, '2024-12-18', 1040, 875, 875
                    , 875, 875, 875, 875
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,875, 875, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1040, sellCostBuyPrice =sellCostBuyPrice+875
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+875, sellCostMeanBuyPrice = sellCostMeanBuyPrice+875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+875, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+875
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+875
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+875
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 875, 875
                    , 875, 875, 875, 875, 875, 875)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1040, netSellCostBuyPrice = netSellCostBuyPrice+875
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+875
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+875
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+875
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+875
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+875
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+875
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+875;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150021 and newid=150088 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:42:06";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:12:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:12:06', '2', 'editprint', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150088');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:43:06";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:13:06", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:13:06', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762d524923c2
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6262,@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-18 15:59:00', '06762d524923c2', '6262', '-500.00', '2106', '30', '1', '2636.00', '2606', '0', '2606', '1', '2024-12-18 17:13:06', '', '75', '0', 'ام ماسة 41', '2', '1', '3', '87', 'ام ماسة 41', '8' ,'0','','','','','-1','0','0','0','0','0','2606','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '2106', userid = '75' WHERE clientid = '6262';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6262','-500.00','2606','0','اضافة فاتورة مبيعات','150089', '2106', '2024-12-18 17:13:06', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2606', '0', null, '0', null, null,'', '0','1','1','2606','1','2024-12-18 15:59:00','0','0');
UPDATE client SET  inUse = 0 where clientid = 6262;
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', '150089', '5', '16250', '1', '300', '300', '0', '', '1', '2024-12-18 17:13:06', '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 = 548379;
 INSERT INTO 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-18', 296.58573596358, 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+296.58573596358, 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-18', 296.58573596358, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+296.58573596358, 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 = '10', userid = '75', storedetaildate = '2024-12-18 17:13:06' WHERE storedetailid = '16249';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16250', '1', '1', '1', '150089', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-18 17:13:06','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', '150089', '5', '16451', '1', '390', '390', '0', '', '1', '2024-12-18 17:13:06', '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 = 548380;
 INSERT INTO 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-18', 385.56145675266, 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+385.56145675266, 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-18', 385.56145675266, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+385.56145675266, 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 = '27', userid = '75', storedetaildate = '2024-12-18 17:13:06' WHERE storedetailid = '16450';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16451', '1', '1', '1', '150089', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28', '27', '75', '2024-12-18 17:13:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 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', '150089', '5', '16117', '1', '280', '280', '0', '', '1', '2024-12-18 17:13:06', '16117', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35712-1,','1','1','0','0','280','280','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 = 548381;
 INSERT INTO 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-18', 276.81335356601, 240, 240
                    , 235, 240, 235, 227.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 229, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+276.81335356601, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+227.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+229
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 276.81335356601, 240, 240
                    , 235, 240, 235, 227.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 229, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+276.81335356601, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+227.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+229
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '75', storedetaildate = '2024-12-18 17:13:06' WHERE storedetailid = '16116';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16117', '1', '1', '1', '150089', 'اضافة فاتورة مبيعات', 'sellbillController.php', '35', '34', '75', '2024-12-18 17:13:06','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', '150089', '5', '16266', '1', '210', '210', '0', '', '1', '2024-12-18 17:13:07', '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 = 548382;
 INSERT INTO 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-18', 207.61001517451, 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+207.61001517451, 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-18', 207.61001517451, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+207.61001517451, 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 = '4', userid = '75', storedetaildate = '2024-12-18 17:13:07' WHERE storedetailid = '16265';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16266', '1', '1', '1', '150089', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 17:13:07','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36160;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07273', '150089', '5', '16395', '1', '600', '600', '0', '', '1', '2024-12-18 17:13:07', '16395', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36160-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 499.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 499.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 500, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 548383;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16395, '2024-12-18', 593.17147192716, 500, 500
                    , 499, 500, 499, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 500, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+593.17147192716, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+499
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+499
                            , 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-18', 593.17147192716, 500, 500
                    , 499, 500, 499, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 500, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+593.17147192716, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+499
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+499
                            , 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 = '41', userid = '75', storedetaildate = '2024-12-18 17:13:07' WHERE storedetailid = '16394';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16395', '1', '1', '1', '150089', 'اضافة فاتورة مبيعات', 'sellbillController.php', '42', '41', '75', '2024-12-18 17:13:07','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', '150089', '5', '16454', '1', '810', '810', '0', '', '1', '2024-12-18 17:13:07', '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 = 745.00, lastbuyprice_withDiscount = 745.00, meanbuyprice_withDiscount = 745.00
        , lastbuyprice_withTax = 745, meanbuyprice_withTax = 745, lastbuyprice_withDiscountAndTax = 745
                where sellbilldetailid = 548384;
 INSERT INTO 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-18', 800.78148710167, 745, 745
                    , 745, 745, 745, 745
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 745, 745, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800.78148710167, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+745
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+745
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+745
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+745
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 800.78148710167, 745, 745
                    , 745, 745, 745, 745
                    , 0, 0, 0, 0
                    , 0, 0, 0, 745, 745, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800.78148710167, sellCostBuyPrice =sellCostBuyPrice+745
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+745, sellCostMeanBuyPrice = sellCostMeanBuyPrice+745
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+745, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+745
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+745
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+745
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+745
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 17:13:07' WHERE storedetailid = '16453';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16454', '1', '1', '1', '150089', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-18 17:13:07','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', '150089', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 17:13:07', '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', '150089', '17', '10291', '1', '26', '26', '0', '', '1', '2024-12-18 17:13:07', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','26','26','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 87 where clientid = 6262;
 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-18', 2606, 2190, 2190
                    , 2184, 2190, 2184, 2177.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2190, 2179, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2606, sellCostBuyPrice =sellCostBuyPrice+2190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2177.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2179
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (6262, '2024-12-18', 2606, 2190, 2190
                    , 2184, 2190, 2184, 2177.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2190, 2179, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2606, sellCostBuyPrice =sellCostBuyPrice+2190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2177.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2179
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 2606, 2190, 2190
                    , 2184, 2190, 2184, 2177.5, 2190, 2179)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2606, netSellCostBuyPrice = netSellCostBuyPrice+2190
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2190
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2184
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2190
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2184
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2177.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2190
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2179;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762d524923c2 and sellbillId = 150089 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:43:07";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:13:07", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:13:07', '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-18 13:46:51";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:16:51", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:16:51', '2', 'addAndRetuen', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e5de22454
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6911,@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-18 17:10:22', '06762e5de22454', '6911', '48.00', '2190', '0', '1', '2142.00', '2142', '0', '2142', '1', '2024-12-18 17:16:51', '', '2', '0', 'همت مصطفي P9', '2', '1', '3', '82', 'همت مصطفي P9', '8' ,'0','','','','','-1','0','0','0','0','0','2142','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '2190', userid = '2' WHERE clientid = '6911';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6911','48.00','2142','0','اضافة فاتورة مبيعات','150090', '2190', '2024-12-18 17:16:51', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2142', '0', null, '0', null, null,'', '0','1','1','2142','1','2024-12-18 17:10:22','0','0');
UPDATE client SET  inUse = 0 where clientid = 6911;
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', '150090', '14', '16388', '1', '670', '670', '0', '', '1', '2024-12-18 17:16:52', '16388', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36146-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 = 548387;
 INSERT INTO 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-18', 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-18', 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 = '19', userid = '2', storedetaildate = '2024-12-18 17:16:52' WHERE storedetailid = '16387';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16388', '1', '1', '1', '150090', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '2', '2024-12-18 17:16:52','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35606;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07050', '150090', '5', '16037', '1', '210', '210', '0', '', '1', '2024-12-18 17:16:52', '16037', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35606-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 164.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 164.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 163, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 548388;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16037, '2024-12-18', 210, 165, 165
                    , 164, 165, 164, 162.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 163, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+164
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+164
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+162.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+163
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 210, 165, 165
                    , 164, 165, 164, 162.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 163, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+164
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+164
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+162.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+163
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 17:16:52' WHERE storedetailid = '16036';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16037', '1', '1', '1', '150090', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '2', '2024-12-18 17:16:52','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 33218;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06240', '150090', '5', '14193', '2', '250', '500', '0', '', '1', '2024-12-18 17:16:52', '14193', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33218-2,','1','1','0','0','250','500','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 = 548389;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14193, '2024-12-18', 500, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 500, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 17:16:52' WHERE storedetailid = '14192';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14193', '1', '2', '1', '150090', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '4', '2', '2024-12-18 17:16:52','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', '150090', '14', '16447', '1', '480', '480', '0', '', '1', '2024-12-18 17:16:52', '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 = 548390;
 INSERT INTO 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-18', 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-18', 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 = '18', userid = '2', storedetaildate = '2024-12-18 17:16:52' WHERE storedetailid = '16446';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16447', '1', '1', '1', '150090', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '2', '2024-12-18 17:16:52','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', '150090', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-18 17:16:52', '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 = 548391;
 INSERT INTO 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-18', 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-18', 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 = '47', userid = '2', storedetaildate = '2024-12-18 17:16:52' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '1', '150090', 'اضافة فاتورة مبيعات', 'sellbillController.php', '48', '47', '2', '2024-12-18 17:16: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', '150090', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 17:16: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', '150090', '17', '10291', '1', '22', '22', '0', '', '1', '2024-12-18 17:16:52', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','22','22','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 82 where clientid = 6911;
 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-18', 2142, 1755, 1755
                    , 1754, 1755, 1754, 1752.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1315, 1311, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2142, sellCostBuyPrice =sellCostBuyPrice+1755
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1755, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1754
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1755, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1754
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1752.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1315
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1311
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (6911, '2024-12-18', 2142, 1755, 1755
                    , 1754, 1755, 1754, 1752.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1315, 1311, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2142, sellCostBuyPrice =sellCostBuyPrice+1755
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1755, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1754
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1755, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1754
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1752.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1315
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1311
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 2142, 1755, 1755
                    , 1754, 1755, 1754, 1752.5, 1315, 1311)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2142, netSellCostBuyPrice = netSellCostBuyPrice+1755
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1755
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1754
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1755
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1754
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1752.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1315
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1311;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e5de22454 and sellbillId = 150090 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:46:52";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:16:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:16:52', '2', '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-18 13:47:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:17:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:17:06', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e5bb2844c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10232,@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-18 17:09:47', '06762e5bb2844c', '10232', '0.00', '490', '0', '1', '490.00', '490', '0', '490', '1', '2024-12-18 17:17:06', '', '104', '0', 'مدام توتة 99', '1', '1', '3', '54', 'مدام توتة 99', '4' ,'0','','','','','-1','0','0','0','0','0','490','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '490', userid = '104' WHERE clientid = '10232';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10232','0.00','490','0','اضافة فاتورة مبيعات','150091', '490', '2024-12-18 17:17:06', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '490', '0', null, '0', null, null,'', '0','1','1','490','1','2024-12-18 17:09:47','0','0');
UPDATE client SET  inUse = 0 where clientid = 10232;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33705;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06547', '150091', '5', '14944', '1', '125', '125', '0', '', '1', '2024-12-18 17:17:06', '14944', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33705-1,','1','1','0','0','125','125','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 1520.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 1520.00
        
                where sellbilldetailid = 548394;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14944, '2024-12-18', 125, 165, 165
                    , 1520, 165, 1520, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1520
                            , 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-18', 125, 165, 165
                    , 1520, 165, 1520, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1520
                            , 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 = '1', userid = '104', storedetaildate = '2024-12-18 17:17:06' WHERE storedetailid = '14943';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14944', '1', '1', '1', '150091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-18 17:17:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33896;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06657', '150091', '5', '15119', '1', '235', '235', '0', '', '1', '2024-12-18 17:17:06', '15119', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33896-1,','1','1','0','0','235','235','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 = 548395;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15119, '2024-12-18', 235, 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+235, 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-18', 235, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, 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 = '104', storedetaildate = '2024-12-18 17:17:06' WHERE storedetailid = '15118';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15119', '1', '1', '1', '150091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-18 17:17:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 22930;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0K496', '150091', '7', '10471', '1', '125', '125', '0', '', '1', '2024-12-18 17:17:06', '10471', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','22930-1,','1','1','0','0','125','125','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 = 548396;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10471, '2024-12-18', 125, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 125, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 17:17:06' WHERE storedetailid = '10470';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10471', '1', '1', '1', '150091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-18 17:17: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 ('0','10291', '150091', '17', '10291', '1', '5', '5', '0', '', '1', '2024-12-18 17:17:06', '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 = 54 where clientid = 10232;
 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-18', 490, 695, 695
                    , 2050, 695, 2050, 695
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+695
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+695, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2050
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+695, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2050
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+695
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (10232, '2024-12-18', 490, 695, 695
                    , 2050, 695, 2050, 695
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+695
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+695, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2050
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+695, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2050
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+695
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 490, 695, 695
                    , 2050, 695, 2050, 695, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+490, netSellCostBuyPrice = netSellCostBuyPrice+695
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+695
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2050
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+695
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2050
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+695
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e5bb2844c and sellbillId = 150091 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:47:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:17:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:17:07', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:49:53";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:19:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 17:19:53', '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-18 13:49:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:19:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:19:54', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e77365ea0
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9653,@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-18 17:17:07', '06762e77365ea0', '9653', '0.00', '207', '0', '1', '207.00', '207', '0', '207', '1', '2024-12-18 17:19:54', '', '104', '0', 'ريموندا 13', '1', '1', '3', '94', 'ريموندا 13', '3' ,'0','','','','','-1','0','0','0','0','0','207','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '207', userid = '104' WHERE clientid = '9653';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9653','0.00','207','0','اضافة فاتورة مبيعات','150092', '207', '2024-12-18 17:19:54', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '207', '0', null, '0', null, null,'', '0','1','1','207','1','2024-12-18 17:17:07','0','0');
UPDATE client SET  inUse = 0 where clientid = 9653;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 28458;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','000D5', '150092', '1', '12674', '1', '125', '125', '0', '', '1', '2024-12-18 17:19:54', '12674', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','28458-1,','1','1','0','0','125','125','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 = 548398;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12674, '2024-12-18', 125, 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+125, 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-18', 125, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, 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 = '0', userid = '104', storedetaildate = '2024-12-18 17:19:54' WHERE storedetailid = '12673';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12674', '1', '1', '1', '150092', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-18 17:19: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 ('50','000M1', '150092', '1', '4724', '1', '80', '80', '0', '', '1', '2024-12-18 17:19:54', '4724', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','80','80','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 = 548399;
 INSERT INTO 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-18', 80, 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+80, 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-18', 80, 50, 50
                    , 50, 50, 50, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+80, 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 = '-147', userid = '104', storedetaildate = '2024-12-18 17:19:54' WHERE storedetailid = '4723';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('4724', '1', '1', '1', '150092', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-146', '-147', '104', '2024-12-18 17:19: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 ('0','10291', '150092', '17', '10291', '1', '2', '2', '0', '', '1', '2024-12-18 17:19:54', '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 = 94 where clientid = 9653;
 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-18', 207, 280, 280
                    , 280, 280, 280, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+207, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9653, '2024-12-18', 207, 280, 280
                    , 280, 280, 280, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+207, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 207, 280, 280
                    , 280, 280, 280, 230, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+207, netSellCostBuyPrice = netSellCostBuyPrice+280
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+280
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+280
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+230
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e77365ea0 and sellbillId = 150092 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:49:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:19:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:19:55', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:50:05";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:20:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:20:05', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149704');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:50:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:20:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:20:57', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:52:48";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:22:48", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:22:48', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e63672356
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1861,@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-18 17:11:50', '06762e63672356', '1861', '0.00', '495', '0', '1', '495.00', '495', '0', '495', '1', '2024-12-18 17:22:48', '', '75', '0', 'رانا ناصر السويس d90', '2', '1', '3', '81', 'رانا ناصر السويس d90', '3' ,'0','','','','','-1','0','0','0','0','0','495','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '495', userid = '75' WHERE clientid = '1861';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1861','0.00','495','0','اضافة فاتورة مبيعات','150093', '495', '2024-12-18 17:22:48', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '495', '0', null, '0', null, null,'', '0','1','1','495','1','2024-12-18 17:11:50','0','0');
UPDATE client SET  inUse = 0 where clientid = 1861;
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', '150093', '1', '16440', '1', '470', '470', '0', '', '1', '2024-12-18 17:22:48', '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 = 548401;
 INSERT INTO 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-18', 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-18', 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 = '40', userid = '75', storedetaildate = '2024-12-18 17:22:48' WHERE storedetailid = '16439';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16440', '1', '1', '1', '150093', 'اضافة فاتورة مبيعات', 'sellbillController.php', '41', '40', '75', '2024-12-18 17:22: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', '150093', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 17:22: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', '150093', '17', '10291', '1', '5', '5', '0', '', '1', '2024-12-18 17:22:48', '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 = 81 where clientid = 1861;
 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-18', 495, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+495, 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 (1861, '2024-12-18', 495, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+495, 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, 495, 400, 400
                    , 400, 400, 400, 400, 400, 400)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+495, 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 06762e63672356 and sellbillId = 150093 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:52:49";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:22:49", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:22:49', '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-18 13:52:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:22:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:22:52', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e85a0631b
-- ----------------------------------------------------------------------------------------------------

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-18 17:20:58', '06762e85a0631b', '1', '0.00', '0', '0', '1', '800.00', '800', '800', '0', '1', '2024-12-18 17:22:53', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150094', '0', '2024-12-18 17:22:53', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '800', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 17:20:58','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29823;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','05989', '150094', '5', '13364', '1', '400', '400', '0', '', '1', '2024-12-18 17:22:53', '13364', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29823-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 495.00 , meanbuyprice = 2140.00, lastbuyprice_withDiscount = 495.00, meanbuyprice_withDiscount = 2140.00
        
                where sellbilldetailid = 548404;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13364, '2024-12-18', 400, 495, 495
                    , 2140, 495, 2140, 492.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+492.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-18', 400, 495, 495
                    , 2140, 495, 2140, 492.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+492.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 = '3', userid = '104', storedetaildate = '2024-12-18 17:22:53' WHERE storedetailid = '13363';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13364', '1', '1', '1', '150094', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-18 17:22:53','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', '150094', '5', '15539', '1', '400', '400', '0', '', '1', '2024-12-18 17:22:53', '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 = 548405;
 INSERT INTO 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-18', 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-18', 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 = '26', userid = '104', storedetaildate = '2024-12-18 17:22:53' WHERE storedetailid = '15538';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15539', '1', '1', '1', '150094', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27', '26', '104', '2024-12-18 17:22:53','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '30395',  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 ('29595','800', '0', '1', 'اضافة فاتورة مبيعات', '150094', '30395', '2024-12-18 17:22:53', '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-18', 800, 840, 840
                    , 2491, 840, 2491, 843.75
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,345, 358, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2491
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2491
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+843.75
                            , 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;
 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-18', 800, 840, 840
                    , 2491, 840, 2491, 843.75
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,345, 358, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2491
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2491
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+843.75
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 800, 840, 840
                    , 2491, 840, 2491, 843.75, 345, 358)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+800, netSellCostBuyPrice = netSellCostBuyPrice+840
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+840
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2491
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+840
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2491
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+843.75
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+345
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+358;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e85a0631b and sellbillId = 150094 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:52:53";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:22:53", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:22:53', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:55:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:25:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:25:17', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:55:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:25:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:25:29', '104', 'add', '192.168.1.13', '', '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', 'يوسف لاحا', '', '75', '2024-12-18', '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 = '30320',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('30395.00','75', '1', '1', 'إضافة مصروف', '25826', '30320', '2024-12-18 17:25:29', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'يوسف لاحا', expensesdetails = '', expensesValue = '75.00', expensesdate = '2024-12-18', 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 = '25826';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:55:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:25:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:25:29', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:55:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:25:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:25:31', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:55:37";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:25:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:25:37', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:55:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:25:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:25:52', '104', 'add', '192.168.1.13', '', '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-18', '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 = '30220',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('30320.00','100', '1', '1', 'إضافة مصروف', '25827', '30220', '2024-12-18 17:25:52', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'عبده صاله', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-18', 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 = '25827';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:55:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:25:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:25:52', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:55:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:25:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:25:54', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:56:39";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:26:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:26:39', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149704');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:58:00";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:28:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:28:00', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247415
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9653,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 17:28:00', userid = '2' WHERE clientid = '9653';
UPDATE client SET  inUse = 0 where clientid = 9653;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9653','207.00','207','1','ايصال تحصيل (( قبض من عميل ))','247415', '0', '2024-12-18 17:04:59', '2', 'clientPayedDeptController.php', '   ', '207', '0', null, '0', null, null,'', '-1','1','1','207','1','','3530','0');
UPDATE save SET  savecurrentvalue = '243765.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('243558.50','207', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247427', '243765.5', '2024-12-18 17:28:00', '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 ('ريموندا 13', 'ريموندا 13', 'ريموندا 13', 'ريموندا 13', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-18 17:28:01');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '207', '207', '2024-12-18', '2', '0', '0', '2024-12-18 17:28:01','اضافة ايصال سداد للعميل ريموندا 13','1','0','0','0','247427','clientPayedDeptController.php?do=show&id=247427');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122179', '-1', '207', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '207', 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 ('122179', '12559', '207', '','0');
UPDATE accountstree SET name = 'ريموندا 13', customName = 'ريموندا 13', customNameEn = 'ريموندا 13', nameEn = 'ريموندا 13', parent = '58', accountNature = '0', theValue = '-207', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 17:28:01' WHERE id = '12559';
UPDATE clientdebtchange SET clientid = '9653', clientdebtchangebefore = '207.000', clientdebtchangeamount = '207.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247415', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 17:04:59', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '207.00',discount='', reciptid='0', dailyentryid = '122179',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='207',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247427';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247415 -clientdebtchangeId = 247427
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:58:01";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:28:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:28:01', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:58:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:28:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:28:11', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e81b7b7dc
-- ----------------------------------------------------------------------------------------------------

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-18 17:19:55', '06762e81b7b7dc', '1', '0.00', '0', '0', '1', '930.00', '930', '930', '0', '1', '2024-12-18 17:28:11', '', '104', '0', 'نقدي', '1', '0', '3', '94', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','930','0','','0','0','930','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150095', '0', '2024-12-18 17:28:11', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '930', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 17:19:55','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35725;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','16005', '150095', '14', '16005', '1', '930', '930', '0', '', '1', '2024-12-18 17:28:11', '16005', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35725-1,','1','1','0','0','930','930','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 = 548406;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16005, '2024-12-18', 930, 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+930, 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-18', 930, 720, 720
                    , 720, 720, 720, 720
                    , 0, 0, 0, 0
                    , 0, 0, 0, 720, 720, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+930, 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 = '104', storedetaildate = '2024-12-18 17:28:11' WHERE storedetailid = '16004';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16005', '1', '1', '1', '150095', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-18 17:28:11','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '31150',  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 ('30220','930', '0', '1', 'اضافة فاتورة مبيعات', '150095', '31150', '2024-12-18 17:28:11', '104',  '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-18', 930, 720, 720
                    , 720, 720, 720, 720
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,720, 720, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+930, 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;
 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-18', 930, 720, 720
                    , 720, 720, 720, 720
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,720, 720, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+930, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 930, 720, 720
                    , 720, 720, 720, 720, 720, 720)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+930, netSellCostBuyPrice = netSellCostBuyPrice+720
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+720
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+720
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+720
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+720
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+720
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+720
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+720;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e81b7b7dc and sellbillId = 150095 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247428
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10232,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 17:28:21', userid = '2' WHERE clientid = '10232';
UPDATE client SET  inUse = 0 where clientid = 10232;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10232','490.00','490','1','ايصال تحصيل (( قبض من عميل ))','247428', '0', '2024-12-18 17:28:01', '2', 'clientPayedDeptController.php', '   ', '490', '0', null, '0', null, null,'', '-1','1','1','490','1','','3531','0');
UPDATE save SET  savecurrentvalue = '244255.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('243765.50','490', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247429', '244255.5', '2024-12-18 17:28:21', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '490', '490', '2024-12-18', '2', '0', '0', '2024-12-18 17:28:22','اضافة ايصال سداد للعميل مدام توتة 99','1','0','0','0','247429','clientPayedDeptController.php?do=show&id=247429');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122180', '-1', '490', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '490', 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 ('122180', '10914', '490', '','0');
UPDATE accountstree SET name = 'مدام توتة 99', customName = 'مدام توتة 99', customNameEn = 'مدام توتة 99', nameEn = 'مدام توتة 99', parent = '58', accountNature = '0', theValue = '-909', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-10-29 16:36:24' WHERE id = '10914';
UPDATE clientdebtchange SET clientid = '10232', clientdebtchangebefore = '490.000', clientdebtchangeamount = '490.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247428', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 17:28:01', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '490.00',discount='', reciptid='0', dailyentryid = '122180',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='490',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247429';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247428 -clientdebtchangeId = 247429
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:58:22";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:28:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:28: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-18 13:58:48";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:28:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:28:48', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247430
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4706,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 17:28:48', userid = '2' WHERE clientid = '4706';
UPDATE client SET  inUse = 0 where clientid = 4706;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4706','1858.00','1858','1','ايصال تحصيل (( قبض من عميل ))','247430', '0', '2024-12-18 17:28:22', '2', 'clientPayedDeptController.php', '   ', '1858', '0', null, '0', null, null,'', '-1','1','1','1858','1','','3532','0');
UPDATE save SET  savecurrentvalue = '246113.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('244255.50','1858', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247430', '246113.5', '2024-12-18 17:28:48', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1858', '1858', '2024-12-18', '2', '0', '0', '2024-12-18 17:28:48','اضافة ايصال سداد للعميل تامر عبدالحميد F88','1','0','0','0','247430','clientPayedDeptController.php?do=show&id=247430');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122181', '-1', '1858', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1858', 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 ('122181', '-1', '1858', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1858', 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 = '4706', clientdebtchangebefore = '1858.000', clientdebtchangeamount = '1858.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247430', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 17:28:22', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1858.00',discount='', reciptid='0', dailyentryid = '122181',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1858',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247430';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247431
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8799,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 17:29:05', userid = '2' WHERE clientid = '8799';
UPDATE client SET  inUse = 0 where clientid = 8799;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8799','179.00','179','1','ايصال تحصيل (( قبض من عميل ))','247431', '0', '2024-12-18 17:28:49', '2', 'clientPayedDeptController.php', '   ', '179', '0', null, '0', null, null,'', '-1','1','1','179','1','','3533','0');
UPDATE save SET  savecurrentvalue = '246292.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('246113.50','179', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247431', '246292.5', '2024-12-18 17:29:05', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '179', '179', '2024-12-18', '2', '0', '0', '2024-12-18 17:29:05','اضافة ايصال سداد للعميل دلال فوزي','1','0','0','0','247431','clientPayedDeptController.php?do=show&id=247431');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122182', '-1', '179', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '179', 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 ('122182', '-1', '179', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-179', 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 = '8799', clientdebtchangebefore = '179.000', clientdebtchangeamount = '179.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247431', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 17:28:49', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '179.00',discount='', reciptid='0', dailyentryid = '122182',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='179',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247431';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 13:59:06";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:29:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:29: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-18 14:00:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:30:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:30:12', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762ea0c961b7
-- ----------------------------------------------------------------------------------------------------

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-18 17:28:12', '06762ea0c961b7', '1', '0.00', '0', '0', '1', '540.00', '540', '540', '0', '1', '2024-12-18 17:30:12', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','540','0','','0','0','540','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150096', '0', '2024-12-18 17:30:12', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '540', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 17:28:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36106;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07265', '150096', '5', '16375', '2', '270', '540', '0', '', '1', '2024-12-18 17:30:12', '16375', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36106-2,','1','1','0','0','270','540','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 = 548407;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16375, '2024-12-18', 540, 430, 430
                    , 430, 430, 430, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 430, 430, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+430
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+430
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+430
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 540, 430, 430
                    , 430, 430, 430, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0, 430, 430, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+430
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+430
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+430
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 17:30:12' WHERE storedetailid = '16374';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16375', '1', '2', '1', '150096', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '8', '104', '2024-12-18 17:30:12','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '31690',  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 ('31150','540', '0', '1', 'اضافة فاتورة مبيعات', '150096', '31690', '2024-12-18 17:30:12', '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-18', 540, 430, 430
                    , 430, 430, 430, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,430, 430, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+430
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+430
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+430
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 540, 430, 430
                    , 430, 430, 430, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,430, 430, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+430
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+430
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+430
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 540, 430, 430
                    , 430, 430, 430, 430, 430, 430)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+540, netSellCostBuyPrice = netSellCostBuyPrice+430
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+430
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+430
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+430
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+430
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+430
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+430
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+430;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762ea0c961b7 and sellbillId = 150096 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:00:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:30:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:30:12', '104', 'addsellBill', '192.168.1.13', '', '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 ('7326','','5','225','285', '285','285', '2024-12-18', '0', '77', '1', '07326', '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 (16493, 1,'2024-12-18 17:30:24',77)
                ON DUPLICATE KEY UPDATE productid = 16493, edited = 1, sysdate = '2024-12-18 17:30: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', '16493', '1', '2024-12-18', '77', '0','1649301','285','285','285','225','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16493', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16493', '1', '0', '0', '16493', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:00:32";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 17:30:32", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 17:30:32', '77', 'add', '192.168.1.21', '', '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 ('06762e20fcdd79', '2024-12-18 16:54:07', '68', '20690.00', '24065', '0', '0', '3375',  '3375', '0', '3375', '1', '2024-12-18 17:30: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 ('07326', '14147', '5', '16493', '15', '225', '3375', '0', '', '2024-12-18 17:30:32', '16493','','','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-18 16:54:07', 1, 16493, 0, 0
                    , 225, 15, 0, 0, 77, '2024-12-18 17:30:32')
                ON DUPLICATE KEY UPDATE buyprice = 225,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 17:30:32' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16493', '225', '15', '0', 'buyBillController.php', '32745', '', '0', '0');
UPDATE product SET  productBuyPrice = "225" WHERE productId = 16493 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32745 ;
UPDATE product SET productName = '7326', productDescription = '', productCatId = '5', productBuyPrice = '225.00', productSellAllPrice = '285.00', productSellUnitPrice = '285.00', productSellHalfPrice = '285.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07326',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 = '16493';
UPDATE buybilldetail SET  lastbuyprice = 225 , meanbuyprice = 225, lastbuyprice_withDiscount = 225, meanbuyprice_withDiscount = 225
        , lastbuyprice_withTax = 225, meanbuyprice_withTax = 225, lastbuyprice_withDiscountAndTax = 225
                where buybilldetailid = 32745;
UPDATE productunit SET proUnitBuyPrice  = 225 * productnumber WHERE productid = 16493;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16492';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16493', '1', '15', '0', '14147', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 16:54:07','0','0');
UPDATE supplier SET  suppliercurrentDebt = '24065',suppliercurrentDebtInCurrency= '24065' , userid = '77', supplierdate = '2024-12-18 17:30:32'   WHERE supplierid = '68';
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 ('68', '20690.00', '3375', '0', 'اضافة فاتورة مشتريات', '14147', '24065', '2024-12-18 16:54:07', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','3375','1','20690','3375','24065','0');
update buybill set dailyentryid='0,' where buybillid=14147;
COMMIT;
UPDATE product SET overAllAveragePrice = 225 WHERE productId = 16493;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:00:32";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 17:30:32", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 17:30:32', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14147');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:00:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:30:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:30:51', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762ea8502efe
-- ----------------------------------------------------------------------------------------------------

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-18 17:30:13', '06762ea8502efe', '1', '0.00', '0', '0', '1', '280.00', '280', '280', '0', '1', '2024-12-18 17:30:51', '', '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-18','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','اضافة فاتورة مبيعات','150097', '0', '2024-12-18 17:30:51', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '280', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 17:30:13','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', '150097', '5', '16334', '1', '280', '280', '0', '', '1', '2024-12-18 17:30:51', '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 = 548408;
 INSERT INTO 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-18', 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-18', 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 = '24', userid = '104', storedetaildate = '2024-12-18 17:30:51' WHERE storedetailid = '16333';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16334', '1', '1', '1', '150097', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '104', '2024-12-18 17:30:51','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '31970',  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 ('31690','280', '0', '1', 'اضافة فاتورة مبيعات', '150097', '31970', '2024-12-18 17:30:51', '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-18', 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-18', 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 06762ea8502efe and sellbillId = 150097 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:00:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:30:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:30:51', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:01:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:31:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:31:14', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762eaabeda3a
-- ----------------------------------------------------------------------------------------------------

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-18 17:30:51', '06762eaabeda3a', '1', '0.00', '0', '0', '1', '160.00', '160', '160', '0', '1', '2024-12-18 17:31:14', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','160','0','','0','0','160','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150098', '0', '2024-12-18 17:31:14', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '160', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 17:30:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36164;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3332', '150098', '1', '16399', '1', '160', '160', '0', '', '1', '2024-12-18 17:31:14', '16399', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36164-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 = 548409;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16399, '2024-12-18', 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-18', 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 = '9', userid = '104', storedetaildate = '2024-12-18 17:31:14' WHERE storedetailid = '16398';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16399', '1', '1', '1', '150098', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-18 17:31:14','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '32130',  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 ('31970','160', '0', '1', 'اضافة فاتورة مبيعات', '150098', '32130', '2024-12-18 17:31:14', '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-18', 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;
 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-18', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 160, 110, 110
                    , 110, 110, 110, 110, 110, 110)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+160, netSellCostBuyPrice = netSellCostBuyPrice+110
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+110
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+110
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+110
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+110
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+110
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+110
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+110;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762eaabeda3a and sellbillId = 150098 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:01:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:31:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:31:15', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:02:28";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 17:32:28", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 17:32:28', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:02:52";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 17:32:52", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 17:32:52', '77', 'add', '192.168.1.21', '', '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 ('06762eb0c76896', '2024-12-18 17:32:28', '235', '34555.00', '36205', '0', '0', '1650',  '1650', '0', '1650', '1', '2024-12-18 17:32:52', '', '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 ('R3342', '14148', '1', '16446', '15', '110', '1650', '0', '', '2024-12-18 17:32:52', '16446','','','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-18 17:32:28', 1, 16446, 0, 0
                    , 110, 15, 0, 0, 77, '2024-12-18 17:32:52')
                ON DUPLICATE KEY UPDATE buyprice = 110,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 17:32:52' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16446', '110', '15', '0', 'buyBillController.php', '32746', '', '0', '0');
UPDATE product SET  productBuyPrice = "110" WHERE productId = 16446 ;
UPDATE buybilldetail SET  quantitybefore = 11 WHERE buybilldetailid = 32746 ;
UPDATE product SET productName = 'R3342', productDescription = '', productCatId = '1', productBuyPrice = '110.00', productSellAllPrice = '160.00', productSellUnitPrice = '160.00', productSellHalfPrice = '160.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3342',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 = '16446';
UPDATE buybilldetail SET  lastbuyprice = 110 , meanbuyprice = 110, lastbuyprice_withDiscount = 110, meanbuyprice_withDiscount = 110
        , lastbuyprice_withTax = 110, meanbuyprice_withTax = 110, lastbuyprice_withDiscountAndTax = 110
                where buybilldetailid = 32746;
UPDATE productunit SET proUnitBuyPrice  = 110 * productnumber WHERE productid = 16446;
UPDATE storedetail SET  productquantity = '26', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16445';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16446', '1', '15', '0', '14148', 'اضافة فاتورة مشتريات', 'buyBillController.php', '11', '26', '77', '2024-12-18 17:32:28','0','0');
UPDATE supplier SET  suppliercurrentDebt = '36205',suppliercurrentDebtInCurrency= '36205' , userid = '77', supplierdate = '2024-12-18 17:32:52'   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', '34555.00', '1650', '0', 'اضافة فاتورة مشتريات', '14148', '36205', '2024-12-18 17:32:28', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','1650','1','34555','1650','36205','0');
update buybill set dailyentryid='0,' where buybillid=14148;
COMMIT;
UPDATE product SET overAllAveragePrice = 110 WHERE productId = 16446;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:02:53";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 17:32:53", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 17:32:53', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14148');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:04:13";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:34:13", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:34:13', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762e8c99fe06
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9396,@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-18 17:22:49', '06762e8c99fe06', '9396', '20.00', '1399', '0', '1', '1379.00', '1379', '0', '1379', '1', '2024-12-18 17:34:14', '', '75', '0', 'ناريمان k956', '2', '1', '3', '52', 'ناريمان k956', '5' ,'0','','','','','-1','0','0','0','0','0','1379','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1399', userid = '75' WHERE clientid = '9396';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9396','20.00','1379','0','اضافة فاتورة مبيعات','150099', '1399', '2024-12-18 17:34:14', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1379', '0', null, '0', null, null,'', '0','1','1','1379','1','2024-12-18 17:22:49','0','0');
UPDATE client SET  inUse = 0 where clientid = 9396;
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', '150099', '1', '16322', '1', '365', '365', '0', '', '1', '2024-12-18 17:34:14', '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 = 548410;
 INSERT INTO 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-18', 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-18', 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 = '29', userid = '75', storedetaildate = '2024-12-18 17:34:14' WHERE storedetailid = '16321';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16322', '1', '1', '1', '150099', 'اضافة فاتورة مبيعات', 'sellbillController.php', '30', '29', '75', '2024-12-18 17:34:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35910;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150099', '5', '16297', '1', '580', '580', '0', '', '1', '2024-12-18 17:34:14', '16297', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35910-1,','1','1','0','0','580','580','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 = 548411;
 INSERT INTO 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-18', 580, 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+580, 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-18', 580, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0, 510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, 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 = '94', userid = '75', storedetaildate = '2024-12-18 17:34:14' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '1', '150099', 'اضافة فاتورة مبيعات', 'sellbillController.php', '95', '94', '75', '2024-12-18 17:34:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35956;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06764', '150099', '5', '15328', '1', '400', '400', '0', '', '1', '2024-12-18 17:34:14', '15328', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35956-1,','1','1','0','0','400','400','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 = 548412;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15328, '2024-12-18', 400, 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+400, 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-18', 400, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, 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-18 17:34:14' WHERE storedetailid = '15327';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15328', '1', '1', '1', '150099', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-18 17:34: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', '150099', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 17:34: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', '150099', '17', '10291', '1', '14', '14', '0', '', '1', '2024-12-18 17:34:14', '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 = 52 where clientid = 9396;
 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-18', 1379, 1155, 1155
                    , 1155, 1155, 1155, 1155
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1155, 1155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1379, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9396, '2024-12-18', 1379, 1155, 1155
                    , 1155, 1155, 1155, 1155
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1155, 1155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1379, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1379, 1155, 1155
                    , 1155, 1155, 1155, 1155, 1155, 1155)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1379, netSellCostBuyPrice = netSellCostBuyPrice+1155
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1155
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1155
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1155
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1155
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1155
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1155
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1155;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762e8c99fe06 and sellbillId = 150099 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:04:14";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:34:14", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:34:14', '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-18 14:06:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:36:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:36:07', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:06:20";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 17:36:20", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 17:36:20', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:06:41";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 17:36:41", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 17:36:41', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:06:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:36:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:36:59', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:07:41";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 17:37:41", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 17:37:41', '77', 'add', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=add');
BEGIN;
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 ('R3344','','1','310','310', '310','310', '2024-12-18', '0', '77', '0', 'R3344', '0', '0', '0', '0', '0', '310','310','310','310','310','0','0','0','0','.','0','0','0','310','0','','','0','0','0','','0','0','0','GS1','','','0','-1','-1','0','','0','0','','0','','310','310','0','0','0','0','0','0','0','1','0','0','0','0','-1','0','','310');
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16494', '1.00', '2024-12-18', '77', '0','1649401','310','310','310','310','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16494', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16494', '1', '0', '0', '16494', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16494, 1,'2024-12-18 17:37:41',77)
                ON DUPLICATE KEY UPDATE productid = 16494, edited = 1, sysdate = '2024-12-18 17:37:41', userid = 77;
UPDATE product SET productName = 'R3344', productDescription = '', productCatId = '1', productBuyPrice = '310.00', productSellAllPrice = '310.00', productSellUnitPrice = '310.00', productSellHalfPrice = '310.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '0', parcode = 'R3344',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '310',lastbuyprice_withDiscount = '310',meanbuyprice = '310',meanbuyprice_withDiscount = '310' , productbuypricereal = '310' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='310',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = '',weightedDiscount='0',sortby=null,TypeOfBarcodeInTax='GS1',barcodeInTax='',productNameE='',partNumber='0',vehicleType='-1',company='-1',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='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='310'  WHERE productId = '16494';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:07:43";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 17:37:43", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 17:37:43', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:08:08";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:38:08", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:38:08', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:10:12";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:40:12", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:40:12', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762eb770bc13
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1372,@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-18 17:34:15', '06762eb770bc13', '1372', '11.00', '3284', '0', '1', '3273.00', '3273', '0', '3273', '1', '2024-12-18 17:40:12', '', '75', '0', 'مينا حنا E405', '2', '1', '3', '78', 'مينا حنا E405', '9' ,'0','','','','','-1','0','0','0','0','0','3273','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '3284', userid = '75' WHERE clientid = '1372';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1372','11.00','3273','0','اضافة فاتورة مبيعات','150100', '3284', '2024-12-18 17:40:12', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3273', '0', null, '0', null, null,'', '0','1','1','3273','1','2024-12-18 17:34:15','0','0');
UPDATE client SET  inUse = 0 where clientid = 1372;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34426;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06756', '150100', '5', '15313', '1', '510', '510', '0', '', '1', '2024-12-18 17:40:12', '15313', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34426-1,','1','1','0','0','510','510','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 = 548415;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15313, '2024-12-18', 510, 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+510, 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-18', 510, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+510, 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 = '14', userid = '75', storedetaildate = '2024-12-18 17:40:12' WHERE storedetailid = '15312';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15313', '1', '1', '1', '150100', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-18 17:40:12','0','0');
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', '150100', '14', '16292', '1', '300', '300', '0', '', '1', '2024-12-18 17:40:12', '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 = 548416;
 INSERT INTO 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-18', 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-18', 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 = '26', userid = '75', storedetaildate = '2024-12-18 17:40:13' WHERE storedetailid = '16291';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16292', '1', '1', '1', '150100', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27', '26', '75', '2024-12-18 17:40:13','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', '150100', '14', '16407', '1', '380', '380', '0', '', '1', '2024-12-18 17:40:13', '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 = 548417;
 INSERT INTO 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-18', 380, 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+380, 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-18', 380, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, 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 = '10', userid = '75', storedetaildate = '2024-12-18 17:40:13' WHERE storedetailid = '16406';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16407', '1', '1', '1', '150100', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-18 17:40:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36182;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07074', '150100', '5', '16052', '1', '400', '400', '0', '', '1', '2024-12-18 17:40:13', '16052', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36182-1,','1','1','0','0','400','400','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 = 548418;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16052, '2024-12-18', 400, 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+400, 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-18', 400, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, 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 = '16', userid = '75', storedetaildate = '2024-12-18 17:40:13' WHERE storedetailid = '16051';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16052', '1', '1', '1', '150100', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '75', '2024-12-18 17:40:13','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', '150100', '5', '16451', '1', '390', '390', '0', '', '1', '2024-12-18 17:40:13', '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 = 548419;
 INSERT INTO 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-18', 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-18', 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 = '26', userid = '75', storedetaildate = '2024-12-18 17:40:13' WHERE storedetailid = '16450';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16451', '1', '1', '1', '150100', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27', '26', '75', '2024-12-18 17:40:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36101;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07257', '150100', '5', '16373', '2', '620', '1240', '0', '', '1', '2024-12-18 17:40:13', '16373', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36101-2,','1','1','0','0','620','1240','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 = 550, lastbuyprice_withDiscountAndTax = 550
                where sellbilldetailid = 548420;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16373, '2024-12-18', 1240, 1100, 1100
                    , 1100, 1100, 1100, 1100
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 1100, 1100, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1240, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1100
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1100
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1100
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1100
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1100
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1240, 1100, 1100
                    , 1100, 1100, 1100, 1100
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1100, 1100, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1240, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1100
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1100
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1100
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1100
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1100
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '75', storedetaildate = '2024-12-18 17:40:13' WHERE storedetailid = '16372';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16373', '1', '2', '1', '150100', 'اضافة فاتورة مبيعات', 'sellbillController.php', '36', '34', '75', '2024-12-18 17:40: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', '150100', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 17:40: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', '150100', '17', '10291', '1', '33', '33', '0', '', '1', '2024-12-18 17:40:13', '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');
UPDATE client SET  delegateid = 78 where clientid = 1372;
 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-18', 3273, 2785, 2785
                    , 2785, 2785, 2785, 2785
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2290, 2290, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3273, sellCostBuyPrice =sellCostBuyPrice+2785
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2785, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2785
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2785, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2785
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2785
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2290
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2290
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (1372, '2024-12-18', 3273, 2785, 2785
                    , 2785, 2785, 2785, 2785
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2290, 2290, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3273, sellCostBuyPrice =sellCostBuyPrice+2785
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2785, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2785
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2785, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2785
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2785
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2290
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2290
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 3273, 2785, 2785
                    , 2785, 2785, 2785, 2785, 2290, 2290)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3273, netSellCostBuyPrice = netSellCostBuyPrice+2785
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2785
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2785
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2785
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2785
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2785
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2290
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2290;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762eb770bc13 and sellbillId = 150100 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:10:13";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:40:13", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:40:13', '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-18 14:11:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:41:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:41:23', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762ec602d728
-- ----------------------------------------------------------------------------------------------------

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-18 17:38:08', '06762ec602d728', '1', '0.00', '0', '0', '1', '810.00', '810', '810', '0', '1', '2024-12-18 17:41:23', '', '104', '0', 'نقدي', '1', '0', '3', '95', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','810','0','','0','0','810','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150101', '0', '2024-12-18 17:41:23', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '810', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 17:38:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35968;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150101', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-18 17:41:23', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35968-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 = 548423;
 INSERT INTO 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-18', 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-18', 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 = '52', userid = '104', storedetaildate = '2024-12-18 17:41:23' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '150101', 'اضافة فاتورة مبيعات', 'sellbillController.php', '53', '52', '104', '2024-12-18 17:41:23','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '32940',  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 ('32130','810', '0', '1', 'اضافة فاتورة مبيعات', '150101', '32940', '2024-12-18 17:41:23', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 95 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-18', 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;
 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-18', 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;
 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 06762ec602d728 and sellbillId = 150101 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762ed24bd5aa
-- ----------------------------------------------------------------------------------------------------

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-18 17:41:24', '06762ed24bd5aa', '1', '0.00', '0', '0', '1', '240.00', '240', '240', '0', '1', '2024-12-18 17:42:18', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150102', '0', '2024-12-18 17:42:18', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '240', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 17:41:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31335;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2823', '150102', '1', '14071', '1', '240', '240', '0', '', '1', '2024-12-18 17:42:18', '14071', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31335-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 215.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 215.00
        
                where sellbilldetailid = 548424;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14071, '2024-12-18', 240, 190, 190
                    , 215, 190, 215, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , 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-18', 240, 190, 190
                    , 215, 190, 215, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , 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 = '6', userid = '104', storedetaildate = '2024-12-18 17:42:18' WHERE storedetailid = '14070';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14071', '1', '1', '1', '150102', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-18 17:42:18','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '33180',  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 ('32940','240', '0', '1', 'اضافة فاتورة مبيعات', '150102', '33180', '2024-12-18 17:42:18', '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-18', 240, 190, 190
                    , 215, 190, 215, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , 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-18', 240, 190, 190
                    , 215, 190, 215, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , 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, 240, 190, 190
                    , 215, 190, 215, 190, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+240, netSellCostBuyPrice = netSellCostBuyPrice+190
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+190
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+215
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+190
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+215
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+190
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762ed24bd5aa and sellbillId = 150102 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:12:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:42:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:42:19', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:13:10";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:43:10", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:43:10', '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-18 14:13:24";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:43:24", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:43:24', '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-18 14:14:21";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:44:21", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:44: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 06762ecde0834f
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(490,@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-18 17:40:14', '06762ecde0834f', '490', '0.00', '354', '0', '1', '354.00', '354', '0', '354', '1', '2024-12-18 17:44:21', '', '75', '0', 'دينا هشام العبور ', '2', '1', '3', '78', 'دينا هشام العبور ', '2' ,'0','','','','','-1','0','0','0','0','0','354','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '354', userid = '75' WHERE clientid = '490';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('490','0.00','354','0','اضافة فاتورة مبيعات','150103', '354', '2024-12-18 17:44:21', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '354', '0', null, '0', null, null,'', '0','1','1','354','1','2024-12-18 17:40:14','0','0');
UPDATE client SET  inUse = 0 where clientid = 490;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36024;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1635', '150103', '14', '16351', '1', '350', '350', '0', '', '1', '2024-12-18 17:44:21', '16351', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36024-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 = 548425;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16351, '2024-12-18', 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-18', 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 = '16', userid = '75', storedetaildate = '2024-12-18 17:44:21' WHERE storedetailid = '16350';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16351', '1', '1', '1', '150103', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '75', '2024-12-18 17:44: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 ('0','10291', '150103', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-18 17:44:21', '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 = 490;
 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-18', 354, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+354, 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 (490, '2024-12-18', 354, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+354, 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, 354, 280, 280
                    , 280, 280, 280, 280, 280, 280)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+354, 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 06762ecde0834f and sellbillId = 150103 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:14:22";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:44:22", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:44: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-18 14:14:26";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:44:26", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:44: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-18 14:14:53";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:44:53", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:44:53', '101', 'delete', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=delete&sellbillid=148861&action=0');

-- ----------------------------------------------------------------------------------------------------
-- bill delete start - sellbill with id = 148861
-- ----------------------------------------------------------------------------------------------------

BEGIN;
UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 148861;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 17:44:53', userid = '75',delbyuserid = '101', conditions = '1'  ,billReservation= 0,billReservationDate='0000-00-00'  WHERE sellbillid = '148861';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35808;
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 = 543786;
 INSERT INTO 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-18', 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-18', 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 = '11', userid = '101', storedetaildate = '2024-12-18 17:44:53' WHERE storedetailid = '15981';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15982', '1', '1', '0', '148861', 'حذف فاتورة مبيعات', 'sellbillController.php', '10', '11', '101', '2024-12-18 17:44:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 30781;
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        
                where sellbilldetailid = 543787;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13823, '2024-12-18', 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-18', 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 = '5', userid = '101', storedetaildate = '2024-12-18 17:44:53' WHERE storedetailid = '13822';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13823', '1', '1', '0', '148861', 'حذف فاتورة مبيعات', 'sellbillController.php', '4', '5', '101', '2024-12-18 17:44:53','0','0');
CALL clientInUse(9939,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '101' WHERE clientid = '9939';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9939','833.00','833.00','1','حذف فاتورة مبيعات','148861', '0', '2024-12-18 17:44:53', '101', 'sellbillController.php', 'حذف فاتورة مبيعات', '833', '0', null, '0', null, null,'', '0','1','1','833','1','2024-12-10 17:58:59','0','0');
UPDATE client SET  inUse = 0 where clientid = 9939;
 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-18', 833, 710, 710
                    , 711, 710, 711, 712
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,360, 362, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-833, sellCostBuyPrice =sellCostBuyPrice-710
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-710, sellCostMeanBuyPrice = sellCostMeanBuyPrice-711
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-710, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-711
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-712
                            , 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9939, '2024-12-18', 833, 710, 710
                    , 711, 710, 711, 712
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 362, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-833, sellCostBuyPrice =sellCostBuyPrice-710
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-710, sellCostMeanBuyPrice = sellCostMeanBuyPrice-711
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-710, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-711
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-712
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 833, 710, 710
                    , 711, 710, 711, 712, 360, 362)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-833, netSellCostBuyPrice = netSellCostBuyPrice-710
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-710
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-711
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-710
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-711
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-712
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-360
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-362;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill delete end - sellbill with id = 148861
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:14:54";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:44:54", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:44:54', '101', 'sucess', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:14:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:44:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:44:55', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762ed5b65641
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3677,@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-18 17:42:19', '06762ed5b65641', '3677', '-7615.00', '-6955', '0', '1', '990.00', '990', '330', '660', '1', '2024-12-18 17:44:56', '', '104', '0', 'زيادة ', '1', '1', '3', '74', 'زيادة ', '3' ,'0','','','','','-1','0','0','0','0','0','990','0','','0','0','330','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '-6955', userid = '104' WHERE clientid = '3677';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3677','-7615.00','660','0','اضافة فاتورة مبيعات','150104', '-6955', '2024-12-18 17:44:56', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '990', '0', null, '0', null, null,'', '0','1','1','660','1','2024-12-18 17:42:19','0','0');
UPDATE client SET  inUse = 0 where clientid = 3677;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3344', '150104', '1', '16494', '3', '330', '990', '0', '', '1', '2024-12-18 17:44:56', '16494', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','330','990','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 = 548427;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16494, '2024-12-18', 990, 930, 930
                    , 930, 930, 930, 930
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 930, 930, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+990, sellCostBuyPrice =sellCostBuyPrice+930
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+930, sellCostMeanBuyPrice = sellCostMeanBuyPrice+930
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+930, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+930
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+930
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+930
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+930
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 990, 930, 930
                    , 930, 930, 930, 930
                    , 0, 0, 0, 0
                    , 0, 0, 0, 930, 930, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+990, sellCostBuyPrice =sellCostBuyPrice+930
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+930, sellCostMeanBuyPrice = sellCostMeanBuyPrice+930
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+930, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+930
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+930
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+930
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+930
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 17:44:56' WHERE storedetailid = '16493';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16494', '1', '3', '1', '150104', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-3', '104', '2024-12-18 17:44:56','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '33510',  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 ('33180','330', '0', '1', 'اضافة فاتورة مبيعات', '150104', '33510', '2024-12-18 17:44:56', '104',  'sellbillController.php','3677','','0');
UPDATE client SET  delegateid = 74 where clientid = 3677;
 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-18', 990, 930, 930
                    , 930, 930, 930, 930
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,930, 930, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+990, sellCostBuyPrice =sellCostBuyPrice+930
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+930, sellCostMeanBuyPrice = sellCostMeanBuyPrice+930
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+930, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+930
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+930
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+930
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+930
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (3677, '2024-12-18', 990, 930, 930
                    , 930, 930, 930, 930
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,930, 930, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+990, sellCostBuyPrice =sellCostBuyPrice+930
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+930, sellCostMeanBuyPrice = sellCostMeanBuyPrice+930
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+930, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+930
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+930
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+930
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+930
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 930, 930
                    , 930, 930, 930, 930, 930, 930)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+990, netSellCostBuyPrice = netSellCostBuyPrice+930
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+930
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+930
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+930
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+930
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+930
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+930
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+930;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762ed5b65641 and sellbillId = 150104 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:14:56";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:44:56", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:44:56', '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-18 14:14:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:44:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:44:56', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:15:07";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:45:07", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:45:07', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762edda7a447
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5780,@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-18 17:44:26', '06762edda7a447', '5780', '0.00', '2455', '0', '1', '2455.00', '2455', '0', '2455', '1', '2024-12-18 17:45:07', '', '75', '0', 'اية حسين كفر الدوار 58', '2', '1', '3', '80', 'اية حسين كفر الدوار 58', '4' ,'0','','','','','-1','0','0','0','0','0','2455','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '2455', userid = '75' WHERE clientid = '5780';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5780','0.00','2455','0','اضافة فاتورة مبيعات','150105', '2455', '2024-12-18 17:45:07', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2455', '0', null, '0', null, null,'', '0','1','1','2455','1','2024-12-18 17:44:26','0','0');
UPDATE client SET  inUse = 0 where clientid = 5780;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 35968;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150105', '5', '16205', '3', '810', '2430', '0', '', '1', '2024-12-18 17:45:07', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35968-3,','1','1','0','0','810','2430','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 = 548428;
 INSERT INTO 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-18', 2430, 2190, 2190
                    , 2190, 2190, 2190, 2190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 2190, 2190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2430, sellCostBuyPrice =sellCostBuyPrice+2190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2190
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 2430, 2190, 2190
                    , 2190, 2190, 2190, 2190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2190, 2190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2430, sellCostBuyPrice =sellCostBuyPrice+2190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2190
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '75', storedetaildate = '2024-12-18 17:45:07' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '3', '1', '150105', 'اضافة فاتورة مبيعات', 'sellbillController.php', '52', '49', '75', '2024-12-18 17:45:07','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', '150105', '17', '10291', '1', '25', '25', '0', '', '1', '2024-12-18 17:45:07', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','25','25','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 80 where clientid = 5780;
 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-18', 2455, 2190, 2190
                    , 2190, 2190, 2190, 2190
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2190, 2190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2455, sellCostBuyPrice =sellCostBuyPrice+2190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2190
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (5780, '2024-12-18', 2455, 2190, 2190
                    , 2190, 2190, 2190, 2190
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2190, 2190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2455, sellCostBuyPrice =sellCostBuyPrice+2190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2190
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 2455, 2190, 2190
                    , 2190, 2190, 2190, 2190, 2190, 2190)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2455, netSellCostBuyPrice = netSellCostBuyPrice+2190
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2190
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2190
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2190
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2190
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2190
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2190
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2190;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762edda7a447 and sellbillId = 150105 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:15:07";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:45:07", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:45:07', '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-18 14:15:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:45:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:45:09', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:16:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:46:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 17:46:11', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.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 ('مروة سعد علي 43' , '', '', '01016157936', '0', '', '0', '2024-12-18 17:46:15', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-18','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10743', '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 ('10743','0','0','0','إضافة عميل جديد','10743', '0', '2024-12-18 17:46:15', '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 ('مروة سعد علي 43', 'مروة سعد علي 43', 'مروة سعد علي 43', 'مروة سعد علي 43', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-18 17:46:15');
UPDATE client SET clientname = 'مروة سعد علي 43', clientaddress = '', clientphone = '', clientmobile = '01016157936', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-18', 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='12560',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10743';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:16:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:46:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 17:46:23', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=add');
BEGIN;
CALL supplierInUse(47,@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 ('47', '5425.00', '15000', '1', 'ايصال دفع لمورد', '1', '-9575', '2024-12-18 17:46:11', '104', 'supplierPayedDeptController.php', '', '0','1', '-1','1','1','15000','1','0','0','0','406');
UPDATE supplierdebtchange SET supplierid = '47', supplierdebtchangebefore = '5425.00', supplierdebtchangeamount = '15000', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '-9575', supplierdebtchangedate = '2024-12-18 17:46:11', userid = '104', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='15000',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='5425',debtchangamountInSupplierCurrency='-9575',debtchangafterInSupplierCurrency='-9575', paySerialNo='406' WHERE supplierdebtchangeid = '26812';
UPDATE supplier SET  suppliercurrentDebt = '-9575',suppliercurrentDebtInCurrency= '-9575' , userid = '104', supplierdate = '2024-12-18 17:46:23'   WHERE supplierid = '47';
UPDATE supplier SET  inUse = 0 where supplierid = 47;
UPDATE save SET  savecurrentvalue = '18510',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('33510.00','15000', '1', '1', 'ايصال دفع لمورد', '26812', '18510', '2024-12-18 17:46:23', '104',  'supplierPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '15000', '15000', '2024-12-18', '104', '0', '0', '2024-12-18 17:46:23','ايصال دفع لمورد ( CATS ) ','1','0','-1','0','26812','supplierReportsController.php?do=show&id=26812');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122183', '-1', '15000', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '15000', 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 ('122183', '-1', '15000', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-15000', 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 = '47', supplierdebtchangebefore = '5425.00', supplierdebtchangeamount = '15000.00', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '-9575.00', supplierdebtchangedate = '2024-12-18 17:46:11', userid = '104', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '122183',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='15000',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='5425',debtchangamountInSupplierCurrency='-9575',debtchangafterInSupplierCurrency='-9575', paySerialNo='406' WHERE supplierdebtchangeid = '26812';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:16:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:46:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 17:46:24', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:16:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:46:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 17:46:25', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:16:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:46:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 17:46:26', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:16:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:46:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:46:31', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:17:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:47:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:47:02', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762ee580b6cb
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10650,@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-18 17:46:32', '06762ee580b6cb', '10650', '0.00', '260', '20', '1', '280.00', '260', '0', '260', '1', '2024-12-18 17:47:02', '', '104', '0', 'عمرو محاسب برادا', '1', '1', '3', '8', 'عمرو محاسب برادا', '1' ,'0','','','','','-1','0','0','0','0','0','260','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '260', userid = '104' 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','0.00','260','0','اضافة فاتورة مبيعات','150106', '260', '2024-12-18 17:47:02', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '260', '0', null, '0', null, null,'', '0','1','1','260','1','2024-12-18 17:46:32','0','0');
UPDATE client SET  inUse = 0 where clientid = 10650;
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', '150106', '14', '15853', '1', '280', '280', '0', '', '1', '2024-12-18 17:47:02', '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 = 548430;
 INSERT INTO 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-18', 260, 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+260, 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-18', 260, 220, 220
                    , 220, 220, 220, 220.79
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, 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 = '19', userid = '104', storedetaildate = '2024-12-18 17:47:02' WHERE storedetailid = '15852';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15853', '1', '1', '1', '150106', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '104', '2024-12-18 17:47:02','0','0');
UPDATE client SET  delegateid = 8 where clientid = 10650;
 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-18', 260, 220, 220
                    , 220, 220, 220, 220.79
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10650, '2024-12-18', 260, 220, 220
                    , 220, 220, 220, 220.79
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 260, 220, 220
                    , 220, 220, 220, 220.79, 220, 220)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+260, netSellCostBuyPrice = netSellCostBuyPrice+220
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+220
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+220
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+220
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+220
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+220.79
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+220
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+220;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762ee580b6cb and sellbillId = 150106 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762ee041b1b2
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10743,@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-18 17:45:08', '06762ee041b1b2', '10743', '0.00', '1207', '0', '1', '1207.00', '1207', '0', '1207', '1', '2024-12-18 17:47:32', '', '75', '0', 'مروة سعد علي 43', '2', '1', '3', '91', 'مروة سعد علي 43', '5' ,'0','','','','','-1','0','0','0','0','0','1207','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1207', userid = '75' WHERE clientid = '10743';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10743','0.00','1207','0','اضافة فاتورة مبيعات','150107', '1207', '2024-12-18 17:47:32', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1207', '0', null, '0', null, null,'', '0','1','1','1207','1','2024-12-18 17:45:08','0','0');
UPDATE client SET  inUse = 0 where clientid = 10743;
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', '150107', '14', '16318', '1', '650', '650', '0', '', '1', '2024-12-18 17:47:32', '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 = 548431;
 INSERT INTO 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-18', 650, 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+650, 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-18', 650, 570, 570
                    , 569, 570, 569, 570
                    , 0, 0, 0, 0
                    , 0, 0, 0, 570, 568, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, 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 = '15', userid = '75', storedetaildate = '2024-12-18 17:47:32' WHERE storedetailid = '16317';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16318', '1', '1', '1', '150107', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '75', '2024-12-18 17:47:32','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', '150107', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-18 17:47:32', '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 = 548432;
 INSERT INTO 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-18', 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-18', 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 = '46', userid = '75', storedetaildate = '2024-12-18 17:47:32' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '1', '150107', 'اضافة فاتورة مبيعات', 'sellbillController.php', '47', '46', '75', '2024-12-18 17:47:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35451;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07078', '150107', '5', '16061', '1', '285', '285', '0', '', '1', '2024-12-18 17:47:32', '16061', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35451-1,','1','1','0','0','285','285','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 = 548433;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16061, '2024-12-18', 285, 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+285, 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-18', 285, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+285, 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-18 17:47:32' WHERE storedetailid = '16060';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16061', '1', '1', '1', '150107', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-18 17:47: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', '150107', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 17:47: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', '150107', '17', '10291', '1', '12', '12', '0', '', '1', '2024-12-18 17:47:32', '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 = 91 where clientid = 10743;
 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-18', 1207, 1010, 1010
                    , 1009, 1010, 1009, 1010
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1010, 1006, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1207, sellCostBuyPrice =sellCostBuyPrice+1010
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1010, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1009
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1010, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1009
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1010
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1010
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1006
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (10743, '2024-12-18', 1207, 1010, 1010
                    , 1009, 1010, 1009, 1010
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1010, 1006, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1207, sellCostBuyPrice =sellCostBuyPrice+1010
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1010, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1009
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1010, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1009
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1010
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1010
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1006
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1207, 1010, 1010
                    , 1009, 1010, 1009, 1010, 1010, 1006)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1207, netSellCostBuyPrice = netSellCostBuyPrice+1010
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1010
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1009
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1010
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1009
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1010
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1010
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1006;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762ee041b1b2 and sellbillId = 150107 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:17:33";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 17:47:33", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:47:33', '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-18 14:18:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:48:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:48:11', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762ee76e62ac
-- ----------------------------------------------------------------------------------------------------

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-18 17:47:02', '06762ee76e62ac', '1', '0.00', '0', '0', '1', '280.00', '280', '280', '0', '1', '2024-12-18 17:48:11', '', '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-18','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','اضافة فاتورة مبيعات','150108', '0', '2024-12-18 17:48:11', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '280', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 17:47: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', '150108', '5', '16334', '1', '280', '280', '0', '', '1', '2024-12-18 17:48:11', '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 = 548436;
 INSERT INTO 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-18', 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-18', 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 = '23', userid = '104', storedetaildate = '2024-12-18 17:48:11' WHERE storedetailid = '16333';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16334', '1', '1', '1', '150108', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '104', '2024-12-18 17:48:11','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '18790',  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 ('18510','280', '0', '1', 'اضافة فاتورة مبيعات', '150108', '18790', '2024-12-18 17:48:11', '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-18', 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-18', 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 06762ee76e62ac and sellbillId = 150108 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:18:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:48:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:48:11', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:19:13";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:49:13", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 17:49:13', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:19:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:49:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:49:20', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:19:26";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:49:26", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 17:49:26', '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-18 14:19:36";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:49:36", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:49:36', '101', 'showDetail', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149998');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:20:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:50:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:50:17', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:20:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:50:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:50:25', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:20:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:50:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:50:26', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:20:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:50:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:50:33', '104', 'add', '192.168.1.13', '', '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', '10000', '2024-12-18', '104', '0', '0','','1','1','0','0','10000');
UPDATE save SET  savecurrentvalue = '8790',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('18790.00','10000', '1', '1', 'تحويل امول الى الخزنة  [ شيكات وكمبيالات ] ', '3523', '8790', '2024-12-18 17:50:33', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '645000',  userid = '104' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('635000.00','10000', '0', '8', 'تحويل امول من الخزنة  [ نقدي ] ', '3523', '645000', '2024-12-18 17:50:33', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '8', transfermoneyvalue = '10000.00', transfermoneydate = '2024-12-18', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='10000' WHERE transfermoneyid = '3523';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:20:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:50:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:50:33', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:20:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:50:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:50:34', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:20:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:50:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:50:41', '104', 'add', '192.168.1.13', '', '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-18', '104', '0', '0','','1','1','0','0','5000');
UPDATE save SET  savecurrentvalue = '3790',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8790.00','5000', '1', '1', 'تحويل امول الى الخزنة  [ جمعيه ] ', '3524', '3790', '2024-12-18 17:50:41', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '45000',  userid = '104' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('40000.00','5000', '0', '5', 'تحويل امول من الخزنة  [ نقدي ] ', '3524', '45000', '2024-12-18 17:50:41', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '5', transfermoneyvalue = '5000.00', transfermoneydate = '2024-12-18', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='5000' WHERE transfermoneyid = '3524';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:20:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:50:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:50:42', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:20:43";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:50:43", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:50:43', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:20:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:50:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 17:50:55', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:21:35";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:51:35", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:51:35', '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-18 14:21:59";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:51:59", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:51:59', '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-18 14:22:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:52:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 17:52:07', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:22:54";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:52:54", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:52:54', '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-18 14:23:07";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:53:07", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:53:07', '101', 'editsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=150041');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:23:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:53:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:53:28', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:23:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:53:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 17:53:41', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:23:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:53:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 17:53:50', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:23:54";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 17:53:54", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 17:53:54', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:23:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:53:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:53:56', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:24:11";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 17:54:11", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 17:54:11', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:24:16";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:54:16", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:54:16', '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 = 150041 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


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

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 150041;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 17:54:17', userid = '101',delbyuserid = '101', conditions = '1'  WHERE sellbillid = '150041';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35460;
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 = 548088;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16065, '2024-12-18', 220, 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-220, 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-18', 220, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-220, 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 = '7', userid = '101', storedetaildate = '2024-12-18 17:54:17' WHERE storedetailid = '16064';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16065', '1', '1', '0', '150041', 'تعديل فاتورة مبيعات', 'sellbillController.php', '6', '7', '101', '2024-12-18 15:09:51','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 = 305, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 548089;
 INSERT INTO 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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 335, 305, 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-305
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 305, 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-305
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 17:54:17' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '0', '150041', 'تعديل فاتورة مبيعات', 'sellbillController.php', '33', '34', '101', '2024-12-18 15:09:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 34663;
UPDATE sellbilldetail SET  lastbuyprice = 520.00 , meanbuyprice = 520.00, lastbuyprice_withDiscount = 520.00, meanbuyprice_withDiscount = 520.00
        , lastbuyprice_withTax = 520, meanbuyprice_withTax = 520, lastbuyprice_withDiscountAndTax = 520
                where sellbilldetailid = 548090;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15685, '2024-12-18', 600, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 520, 520, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-600, sellCostBuyPrice =sellCostBuyPrice-520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-520, sellCostMeanBuyPrice = sellCostMeanBuyPrice-520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-520
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-520
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 600, 520, 520
                    , 520, 520, 520, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 520, 520, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-600, sellCostBuyPrice =sellCostBuyPrice-520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-520, sellCostMeanBuyPrice = sellCostMeanBuyPrice-520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-520
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-520
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 17:54:17' WHERE storedetailid = '15684';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15685', '1', '1', '0', '150041', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0', '1', '101', '2024-12-18 15:09:51','0','0');
CALL clientInUse(9026,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '101' WHERE clientid = '9026';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9026','1252.00','1252.00','1','تعديل فاتورة مبيعات','150041', '0', '2024-12-18 15:09:51', '101', 'sellbillController.php', 'تعديل فاتورة مبيعات', '1252', '0', null, '0', null, null,'', '0','1','1','1252','1','2024-12-18 15:09:51','0','0');
UPDATE client SET  inUse = 0 where clientid = 9026;
 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-18', 1252, 1005, 1005
                    , 1005, 1005, 1005, 1005
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1005, 975, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1252, sellCostBuyPrice =sellCostBuyPrice-1005
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1005, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1005
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1005, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1005
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1005
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1005
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-975
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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 (9026, '2024-12-18', 1252, 1005, 1005
                    , 1005, 1005, 1005, 1005
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1005, 975, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1252, sellCostBuyPrice =sellCostBuyPrice-1005
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1005, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1005
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1005, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1005
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1005
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-1005
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-975
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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, 1005, 1005
                    , 1005, 1005, 1005, 1005, 1005, 975)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-1252, netSellCostBuyPrice = netSellCostBuyPrice-1005
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-1005
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-1005
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-1005
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-1005
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-1005
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-1005
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-975;

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


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

COMMIT;
BEGIN;
CALL clientInUse(9026,@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 15:09:51', '06762c99f46a36', '9026', '0.00', '1222', '0', '1', '1222', '1222', '0', '1222', '1', '2024-12-18 15:09:51', '', '101', '0', 'شدن محمد K205', '2', '1', '3', '79', 'شدن محمد K205', '5', '150041', '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 = '1222', userid = '101' WHERE clientid = '9026';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9026','0.00','1222','0','اضافة فاتورة مبيعات (معدله)','150109', '1222', '2024-12-18 17:54:17', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '1222', '0', null, '0', null, null,'', '0','1','1','1252','1','2024-12-18 15:09:51','0','0');
UPDATE client SET  inUse = 0 where clientid = 9026;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35460;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07064', '150109', '5', '16065', '1', '220', '220', '0', '', '1', '2024-12-18 17:54:17', '16065', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35460-1,','1','1','0','0','220','220','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 = 548437;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16065, '2024-12-18', 220, 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+220, 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-18', 220, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 150, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, 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 = '6', userid = '101', storedetaildate = '2024-12-18 17:54:17' WHERE storedetailid = '16064';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16065', '1', '1', '1', '150109', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '7', '6', '101', '2024-12-18 17:54:17','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', '150109', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-18 17:54:17', '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 = 305, lastbuyprice_withDiscountAndTax = 335
                where sellbilldetailid = 548438;
 INSERT INTO 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-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 335, 305, 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+305
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 400, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 305, 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+305
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 17:54: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', '150109', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '34', '33', '101', '2024-12-18 17:54:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36171;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1409', '150109', '14', '15689', '1', '570', '570', '0', '', '1', '2024-12-18 17:54:17', '15689', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36171-1,','1','1','0','0','570','570','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 = 548439;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15689, '2024-12-18', 570, 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+570, 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-18', 570, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0, 490, 490, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+570, 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 = '7', userid = '101', storedetaildate = '2024-12-18 17:54:17' WHERE storedetailid = '15688';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15689', '1', '1', '1', '150109', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '8', '7', '101', '2024-12-18 17:54: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', '150109', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 17:54: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', '150109', '17', '10291', '1', '12', '12', '0', '', '1', '2024-12-18 17:54:17', '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');
 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-18', 1222, 975, 975
                    , 975, 975, 975, 975
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,975, 945, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1222, sellCostBuyPrice =sellCostBuyPrice+975
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+975, sellCostMeanBuyPrice = sellCostMeanBuyPrice+975
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+975, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+975
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+975
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+975
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+945
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (9026, '2024-12-18', 1222, 975, 975
                    , 975, 975, 975, 975
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,975, 945, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1222, sellCostBuyPrice =sellCostBuyPrice+975
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+975, sellCostMeanBuyPrice = sellCostMeanBuyPrice+975
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+975, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+975
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+975
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+975
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+945
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1222, 975, 975
                    , 975, 975, 975, 975, 975, 945)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1222, netSellCostBuyPrice = netSellCostBuyPrice+975
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+975
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+975
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+975
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+975
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+975
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+975
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+945;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 150041 and newid=150109 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:24:18";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:54:18", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:54:18', '101', 'editprint', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150109');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:25:55";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 17:55:55", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 17:55:55', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:26:17";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:56:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:56:17', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247432
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9016,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 17:56:17', userid = '2' WHERE clientid = '9016';
UPDATE client SET  inUse = 0 where clientid = 9016;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9016','1293.00','1293','1','ايصال تحصيل (( قبض من عميل ))','247432', '0', '2024-12-18 17:29:06', '2', 'clientPayedDeptController.php', '   ', '1293', '0', null, '0', null, null,'', '-1','1','1','1293','1','','3534','0');
UPDATE save SET  savecurrentvalue = '247585.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('246292.50','1293', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247449', '247585.5', '2024-12-18 17:56:17', '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 ('لميس فرج P504', 'لميس فرج P504', 'لميس فرج P504', 'لميس فرج P504', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-18 17:56:18');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1293', '1293', '2024-12-18', '2', '0', '0', '2024-12-18 17:56:18','اضافة ايصال سداد للعميل لميس فرج P504','1','0','0','0','247449','clientPayedDeptController.php?do=show&id=247449');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122184', '-1', '1293', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1293', 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 ('122184', '12561', '1293', '','0');
UPDATE accountstree SET name = 'لميس فرج P504', customName = 'لميس فرج P504', customNameEn = 'لميس فرج P504', nameEn = 'لميس فرج P504', parent = '58', accountNature = '0', theValue = '-1293', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 17:56:18' WHERE id = '12561';
UPDATE clientdebtchange SET clientid = '9016', clientdebtchangebefore = '1293.000', clientdebtchangeamount = '1293.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247432', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 17:29:06', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1293.00',discount='', reciptid='0', dailyentryid = '122184',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1293',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247449';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247432 -clientdebtchangeId = 247449
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247450
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4296,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 17:56:42', userid = '2' WHERE clientid = '4296';
UPDATE client SET  inUse = 0 where clientid = 4296;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4296','859.00','859','1','ايصال تحصيل (( قبض من عميل ))','247450', '0', '2024-12-18 17:56:18', '2', 'clientPayedDeptController.php', '   ', '859', '0', null, '0', null, null,'', '-1','1','1','859','1','','3535','0');
UPDATE save SET  savecurrentvalue = '248444.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('247585.50','859', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247450', '248444.5', '2024-12-18 17:56:42', '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 ('مروة ابراهيم k73', 'مروة ابراهيم k73', 'مروة ابراهيم k73', 'مروة ابراهيم k73', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-18 17:56:42');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '859', '859', '2024-12-18', '2', '0', '0', '2024-12-18 17:56:42','اضافة ايصال سداد للعميل مروة ابراهيم k73','1','0','0','0','247450','clientPayedDeptController.php?do=show&id=247450');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122185', '-1', '859', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '859', 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 ('122185', '12562', '859', '','0');
UPDATE accountstree SET name = 'مروة ابراهيم k73', customName = 'مروة ابراهيم k73', customNameEn = 'مروة ابراهيم k73', nameEn = 'مروة ابراهيم k73', parent = '58', accountNature = '0', theValue = '-859', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 17:56:42' WHERE id = '12562';
UPDATE clientdebtchange SET clientid = '4296', clientdebtchangebefore = '859.000', clientdebtchangeamount = '859.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247450', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 17:56:18', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '859.00',discount='', reciptid='0', dailyentryid = '122185',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='859',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247450';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:26:43";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:56:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:56: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-18 14:27:25";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:57:25", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:57:25', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247451
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8406,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 17:57:26', userid = '2' WHERE clientid = '8406';
UPDATE client SET  inUse = 0 where clientid = 8406;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8406','1040.00','1040','1','ايصال تحصيل (( قبض من عميل ))','247451', '0', '2024-12-18 17:56:43', '2', 'clientPayedDeptController.php', '   ', '1040', '0', null, '0', null, null,'', '-1','1','1','1040','1','','3536','0');
UPDATE save SET  savecurrentvalue = '249484.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('248444.50','1040', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247451', '249484.5', '2024-12-18 17:57:26', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1040', '1040', '2024-12-18', '2', '0', '0', '2024-12-18 17:57:26','اضافة ايصال سداد للعميل مي احمد طنطا W351','1','0','0','0','247451','clientPayedDeptController.php?do=show&id=247451');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122186', '-1', '1040', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1040', 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 ('122186', '-1', '1040', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1040', 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 = '8406', clientdebtchangebefore = '1040.000', clientdebtchangeamount = '1040.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247451', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 17:56:43', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1040.00',discount='', reciptid='0', dailyentryid = '122186',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1040',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247451';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:27:26";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:57:26", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:57: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-18 14:27:30";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:57:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:57: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-18 14:27:42";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:57:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:57:42', '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-18 14:27:50";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:57:50", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:57:50', '2', 'editsellBill', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=149998');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:28:13";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:58:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:58:13', '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 = 149998 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


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

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 149998;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 17:58:14', userid = '75',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '149998';
UPDATE sellbilldetail SET  lastbuyprice = 510.00 , meanbuyprice = 505.00, lastbuyprice_withDiscount = 510.00, meanbuyprice_withDiscount = 505.00
        
                where sellbilldetailid = 547951;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9701, '2024-12-18', 640, 510, 510
                    , 505, 510, 505, 501.54
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-640, sellCostBuyPrice =sellCostBuyPrice-510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-510, sellCostMeanBuyPrice = sellCostMeanBuyPrice-505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-501.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 640, 510, 510
                    , 505, 510, 505, 501.54
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-640, sellCostBuyPrice =sellCostBuyPrice-510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-510, sellCostMeanBuyPrice = sellCostMeanBuyPrice-505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-501.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 17:58:14' WHERE storedetailid = '9700';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9701', '1', '1', '0', '149998', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-3', '-2', '2', '2024-12-18 12:49:54','0','0');
CALL clientInUse(6971,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-371', userid = '2' WHERE clientid = '6971';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6971','296.00','667.00','1','تعديل فاتورة مبيعات','149998', '-371', '2024-12-18 12:49:54', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '667', '0', null, '0', null, null,'', '0','1','1','667','1','2024-12-18 12:49:54','0','0');
UPDATE client SET  inUse = 0 where clientid = 6971;
 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-18', 667, 510, 510
                    , 505, 510, 505, 501.54
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-667, sellCostBuyPrice =sellCostBuyPrice-510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-510, sellCostMeanBuyPrice = sellCostMeanBuyPrice-505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-501.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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 (6971, '2024-12-18', 667, 510, 510
                    , 505, 510, 505, 501.54
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-667, sellCostBuyPrice =sellCostBuyPrice-510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-510, sellCostMeanBuyPrice = sellCostMeanBuyPrice-505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-501.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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, 667, 510, 510
                    , 505, 510, 505, 501.54, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-667, netSellCostBuyPrice = netSellCostBuyPrice-510
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-510
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-505
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-510
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-505
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-501.54
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-0;

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


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

COMMIT;
BEGIN;
CALL clientInUse(6971,@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 12:49:54', '06762a8d2c13ec', '6971', '-371.00', '13', '0', '1', '384', '384', '0', '384', '1', '2024-12-18 12:49:54', '', '2', '0', 'جهاد عبدالعزيز X65', '2', '1', '3', '85', 'جهاد عبدالعزيز X65', '3', '149998', '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 = '13', userid = '2' WHERE clientid = '6971';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6971','-371.00','384','0','اضافة فاتورة مبيعات (معدله)','150110', '13', '2024-12-18 17:58:14', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '384', '0', null, '0', null, null,'', '0','1','1','667','1','2024-12-18 12:49:54','0','0');
UPDATE client SET  inUse = 0 where clientid = 6971;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1125', '150110', '14', '9701', '1', '360', '360', '0', '', '1', '2024-12-18 17:58:14', '9701', '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 = 510.00 , meanbuyprice = 505.00, lastbuyprice_withDiscount = 510.00, meanbuyprice_withDiscount = 505.00
        
                where sellbilldetailid = 548442;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9701, '2024-12-18', 360, 510, 510
                    , 505, 510, 505, 501.54
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+501.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 360, 510, 510
                    , 505, 510, 505, 501.54
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+501.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 17:58:14' WHERE storedetailid = '9700';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9701', '1', '1', '1', '150110', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '-2', '-3', '2', '2024-12-18 17:58: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', '150110', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 17:58: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', '150110', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-18 17:58:14', '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');
 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-18', 384, 510, 510
                    , 505, 510, 505, 501.54
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+384, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+501.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (6971, '2024-12-18', 384, 510, 510
                    , 505, 510, 505, 501.54
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+384, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+505
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+505
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+501.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 510, 510
                    , 505, 510, 505, 501.54, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+384, netSellCostBuyPrice = netSellCostBuyPrice+510
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+510
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+505
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+510
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+505
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+501.54
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 149998 and newid=150110 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:28:14";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:58:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:58:14', '2', 'editprint', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150110');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:28:16";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:58:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:58:16', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762f014ce091
-- ----------------------------------------------------------------------------------------------------

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-18 17:53:56', '06762f014ce091', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-18 17:58:16', '', '104', '0', 'نقدي', '1', '0', '3', '95', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150111', '0', '2024-12-18 17:58:16', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 17:53:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33890;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3165', '150111', '1', '15287', '1', '300', '300', '0', '', '1', '2024-12-18 17:58:16', '15287', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33890-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
        
                where sellbilldetailid = 548445;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15287, '2024-12-18', 300, 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+300, 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-18', 300, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, 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 = '7', userid = '104', storedetaildate = '2024-12-18 17:58:16' WHERE storedetailid = '15286';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15287', '1', '1', '1', '150111', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '104', '2024-12-18 17:58:16','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '4090',  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 ('3790','300', '0', '1', 'اضافة فاتورة مبيعات', '150111', '4090', '2024-12-18 17:58:16', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 95 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-18', 300, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, 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 (1, '2024-12-18', 300, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, 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, 300, 235, 235
                    , 235, 235, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, 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 06762f014ce091 and sellbillId = 150111 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247452
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1911,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '65' , clientdate = '2024-12-18 17:58:53', userid = '2' WHERE clientid = '1911';
UPDATE client SET  inUse = 0 where clientid = 1911;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1911','479.00','414','1','ايصال تحصيل (( قبض من عميل ))','247452', '65', '2024-12-18 17:57:26', '2', 'clientPayedDeptController.php', '   ', '414', '0', null, '0', null, null,'', '-1','1','1','414','1','','3537','0');
UPDATE save SET  savecurrentvalue = '249898.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('249484.50','414', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247455', '249898.5', '2024-12-18 17:58:53', '2',  'clientPayedDeptController.php','0','','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:28:53";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:58:53", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:58:53', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '414', '414', '2024-12-18', '2', '0', '0', '2024-12-18 17:58:53','اضافة ايصال سداد للعميل جيجي المقدم73','1','0','0','0','247455','clientPayedDeptController.php?do=show&id=247455');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122187', '-1', '414', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '414', 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 ('122187', '-1', '414', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-414', 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 = '1911', clientdebtchangebefore = '479.000', clientdebtchangeamount = '414.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247452', clientdebtchangeafter = '65.000', clientdebtchangedate = '2024-12-18 17:57:26', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '414.00',discount='', reciptid='0', dailyentryid = '122187',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='414',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247455';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247452 -clientdebtchangeId = 247455
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:28:54";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 17:58:54", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 17:58:54', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:29:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:59:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:59:09', '104', 'add', '192.168.1.13', '', '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', 'مرتجعات', '', '130', '2024-12-18', '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 = '3960',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('4090.00','130', '1', '1', 'إضافة مصروف', '25828', '3960', '2024-12-18 17:59:09', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'مرتجعات', expensesdetails = '', expensesValue = '130.00', expensesdate = '2024-12-18', 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 = '25828';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:29:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:59:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:59:09', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:29:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:59:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 17:59:11', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:29:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 17:59:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 17:59:21', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:30:53";
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-18 14:30:54";
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-18 14:30:54";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:30:54";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:30:54";
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-18 14:30:55";
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-18 14:31:27";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:01:27", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 18:01:27', '77', '', '192.168.1.13', '', '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-18 14:31:28";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:31:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:01:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:01:46', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762f15997296
-- ----------------------------------------------------------------------------------------------------

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-18 17:59:21', '06762f15997296', '10626', '0.00', '1877', '0', '1', '1877.00', '1877', '0', '1877', '1', '2024-12-18 18:01:46', '', '104', '0', 'هند محمد فريد', '1', '1', '3', '74', 'هند محمد فريد', '4' ,'0','','','','','-1','0','0','0','0','0','1877','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1877', 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','1877','0','اضافة فاتورة مبيعات','150112', '1877', '2024-12-18 18:01:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1877', '0', null, '0', null, null,'', '0','1','1','1877','1','2024-12-18 17:59:21','0','0');
UPDATE client SET  inUse = 0 where clientid = 10626;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36086;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3246', '150112', '1', '15659', '1', '560', '560', '0', '', '1', '2024-12-18 18:01:46', '15659', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36086-1,','1','1','0','0','560','560','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 510.00 , meanbuyprice = 503.00, lastbuyprice_withDiscount = 510.00, meanbuyprice_withDiscount = 503.00
        , lastbuyprice_withTax = 510, meanbuyprice_withTax = 497, lastbuyprice_withDiscountAndTax = 510
                where sellbilldetailid = 548446;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15659, '2024-12-18', 560, 510, 510
                    , 503, 510, 503, 445.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 510, 497, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+560, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+445.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+510
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+497
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 560, 510, 510
                    , 503, 510, 503, 445.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 510, 497, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+560, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+503
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+503
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+445.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+510
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+497
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 18:01:46' WHERE storedetailid = '15658';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15659', '1', '1', '1', '150112', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-18 18:01:46','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', '150112', '1', '16277', '2', '650', '1300', '0', '', '1', '2024-12-18 18:01:46', '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 = 548447;
 INSERT INTO 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-18', 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-18', 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 = '49', userid = '104', storedetaildate = '2024-12-18 18:01:46' WHERE storedetailid = '16276';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16277', '1', '2', '1', '150112', 'اضافة فاتورة مبيعات', 'sellbillController.php', '51', '49', '104', '2024-12-18 18:01: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', '150112', '17', '10291', '1', '17', '17', '0', '', '1', '2024-12-18 18:01:46', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','17','17','0','','0','0.00','0','0','0','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-18', 1877, 1610, 1610
                    , 1601, 1610, 1597, 1539.01
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1610, 1593, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1877, sellCostBuyPrice =sellCostBuyPrice+1610
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1610, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1601
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1610, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1597
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1539.01
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1610
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1593
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1877, 1610, 1610
                    , 1601, 1610, 1597, 1539.01
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1610, 1593, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1877, sellCostBuyPrice =sellCostBuyPrice+1610
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1610, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1601
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1610, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1597
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1539.01
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1610
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1593
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1877, 1610, 1610
                    , 1601, 1610, 1597, 1539.01, 1610, 1593)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1877, netSellCostBuyPrice = netSellCostBuyPrice+1610
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1610
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1601
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1610
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1597
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1539.01
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1610
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1593;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762f15997296 and sellbillId = 150112 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:31:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:01:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:01:47', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:31:55";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:01:55", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:01:55', '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-18 14:34:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:04:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:04:33', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762f1eb9bed6
-- ----------------------------------------------------------------------------------------------------

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-18 18:01:47', '06762f1eb9bed6', '1', '0.00', '0', '0', '1', '1630.00', '1630', '1630', '0', '1', '2024-12-18 18:04:34', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '6' ,'0','','','','','-1','0','0','0','0','0','1630','0','','0','0','1630','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150113', '0', '2024-12-18 18:04:34', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1630', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 18:01:47','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', '150113', '14', '16449', '1', '280', '280', '0', '', '1', '2024-12-18 18:04: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 = 548449;
 INSERT INTO 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-18', 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-18', 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 = '20', userid = '104', storedetaildate = '2024-12-18 18:04: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', '150113', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '104', '2024-12-18 18:04:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35843;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3307', '150113', '1', '16120', '1', '370', '370', '0', '', '1', '2024-12-18 18:04:34', '16120', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35843-1,','1','1','0','0','370','370','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 = 548450;
 INSERT INTO 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-18', 370, 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+370, 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-18', 370, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+370, 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 = '9', userid = '104', storedetaildate = '2024-12-18 18:04:34' WHERE storedetailid = '16119';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16120', '1', '1', '1', '150113', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-18 18:04:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 36095;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07255', '150113', '5', '16369', '3', '260', '780', '0', '', '1', '2024-12-18 18:04:34', '16369', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36095-3,','1','1','0','0','260','780','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 = 548451;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16369, '2024-12-18', 780, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, 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+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-18', 780, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, 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 = '36', userid = '104', storedetaildate = '2024-12-18 18:04:34' WHERE storedetailid = '16368';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16369', '1', '3', '1', '150113', 'اضافة فاتورة مبيعات', 'sellbillController.php', '39', '36', '104', '2024-12-18 18:04: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', '150113', '5', '16434', '1', '200', '200', '0', '', '1', '2024-12-18 18:04: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 = 548452;
 INSERT INTO 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-18', 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-18', 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 = '104', storedetaildate = '2024-12-18 18:04: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', '150113', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '104', '2024-12-18 18:04:34','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '5590',  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 ('3960','1630', '0', '1', 'اضافة فاتورة مبيعات', '150113', '5590', '2024-12-18 18:04:34', '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-18', 1630, 1275, 1275
                    , 1275, 1275, 1275, 1275
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1275, 1275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1630, sellCostBuyPrice =sellCostBuyPrice+1275
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1275, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1275
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1275, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1275
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1275
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1275
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1630, 1275, 1275
                    , 1275, 1275, 1275, 1275
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1275, 1275, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1630, sellCostBuyPrice =sellCostBuyPrice+1275
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1275, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1275
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1275, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1275
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1275
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1275
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1275
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1275, 1275
                    , 1275, 1275, 1275, 1275, 1275, 1275)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1630, netSellCostBuyPrice = netSellCostBuyPrice+1275
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1275
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1275
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1275
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1275
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1275
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1275
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1275;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762f1eb9bed6 and sellbillId = 150113 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:34:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:04:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:04:34', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:36:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:06:46", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:06:46', '77', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:37:00";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:07:00", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 18:07:00', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:37:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:07:26", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:07:26', '77', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:37:32";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:07:32", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 18:07:32', '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-18 14:38:01";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:08:01", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:08:01', '101', 'showDetail', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149588');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:39:10";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:09:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 18:09:10', '77', 'oneSupplier', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:39:14";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:09:14", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 18:09:14', '77', 'oneSupplier', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:42:03";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:12:03", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:12:03', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:42:23";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:12:23", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:12:23', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:42:39";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:12:39", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:12:39', '77', 'details', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=details&id=14101');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:42:42";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:12:42", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:12:42', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:42:59";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:12:59", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:12:59', '77', 'show', '192.168.1.21', '', '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-18 14:43:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:13:12", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 18:13:12', '9', '', '192.168.1.13', '', '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-18 14:43:13";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:43:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:13:15", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 18:13:15', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:43:24";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:13:24", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:13:24', '101', 'showDetail', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=146973');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:43:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:13:26", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 18:13:26', '9', 'add', '192.168.1.13', '', '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 ('8','1', '10000', '2024-12-18', '9', '0', '0','','1','1','0','0','10000');
UPDATE save SET  savecurrentvalue = '635000',  userid = '9' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('645000.00','10000', '1', '8', 'تحويل امول الى الخزنة  [ نقدي ] ', '3525', '635000', '2024-12-18 18:13:26', '9',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '15590',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('5590.00','10000', '0', '1', 'تحويل امول من الخزنة  [ شيكات وكمبيالات ] ', '3525', '15590', '2024-12-18 18:13:26', '9',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '8', saveidto = '1', transfermoneyvalue = '10000.00', transfermoneydate = '2024-12-18', userid = '9', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='10000' WHERE transfermoneyid = '3525';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:43:27";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:13:27", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 18:13:27', '9', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:43:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:13:28", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 18:13:28', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:43:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:13:41", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 18:13:41', '9', 'add', '192.168.1.13', '', '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', 'ايجار الترحيله', '', '10000', '2024-12-18', '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 = '5590',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('15590.00','10000', '1', '1', 'إضافة مصروف', '25829', '5590', '2024-12-18 18:13:41', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'ايجار الترحيله', expensesdetails = '', expensesValue = '10000.00', expensesdate = '2024-12-18', 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 = '25829';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:43:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:13:42", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 18:13:42', '9', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
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-18 14:43:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:13:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 18:13:54', '104', '', '192.168.1.13', '', '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-18 14:43:55";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:43:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:13:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:13:57', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:43:57";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:13:57", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:13:57', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:44:41";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:14:41", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:14:41', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.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' , '', '', '01024168722', '0', '', '0', '2024-12-18 18:14:43', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-18','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10744', '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 ('10744','0','0','0','إضافة عميل جديد','10744', '0', '2024-12-18 18:14: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 ('هاجر شبانة 25', 'هاجر شبانة 25', 'هاجر شبانة 25', 'هاجر شبانة 25', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-18 18:14:43');
UPDATE client SET clientname = 'هاجر شبانة 25', clientaddress = '', clientphone = '', clientmobile = '01024168722', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-18', 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='12563',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10744';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:45:27";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:45:27";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:15:27", deviceType = "DESKTOP" WHERE userid = 101;
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:15:27", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:15:27', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:15:27', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762f1f39007a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1778,@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-18 18:01:55', '06762f1f39007a', '1778', '2.00', '-438', '0', '1', '440', '440', '0', '-440', '1', '2024-12-18 18:15:27', '', '101', '0', 'ولاء حسين اسماعلية y49','2', '1', '5', '80', 'ولاء حسين اسماعلية y49', '2', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '-438', userid = '101' WHERE clientid = '1778';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1778','2.00','440','1','اضافة فاتورة مردوات مبيعات','16820', '-438', '2024-12-18 18:15:27', '101', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '440', '0', null, '0', null, null,'', '0','1','1','440','1','2024-12-18 18:01:55','0','0');
UPDATE client SET  inUse = 0 where clientid = 1778;
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 ('165.00', 'R3301', '16820', '1', '16051', '1', '210', '210', '0', '', '1', '0', '16051', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','210','210','0','','0');
UPDATE returnsellbilldetail 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 returnsellbilldetailid = 22002;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16051, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 165, 165, 165
                    , 165, 165, 165, 0, 1, 0, 0, 165, 165)
                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+165, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+165
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+165, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+165
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+165
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+165
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+165
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+165
                        , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 210, 165, 165, 165
                    , 165, 165, 165, 0, 0, 165, 165)
                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+165, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+165
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+165, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+165
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+165
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+165
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+165
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+165;
UPDATE storedetail SET  productquantity = '3', userid = '101', storedetaildate = '2024-12-18 18:15:27' WHERE storedetailid = '16050';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16051', '1', '1', '0', '16820', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '2', '3', '101', '2024-12-18 18:15:27','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 ('140.00', '07062', '16820', '5', '16050', '1', '230', '230', '0', '', '1', '0', '16050', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','230','230','0','','0');
UPDATE returnsellbilldetail 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 returnsellbilldetailid = 22003;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16050, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 230, 140, 140, 140
                    , 140, 140, 140, 0, 1, 0, 0, 140, 140)
                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+230, returnSellCostBuyPrice = returnSellCostBuyPrice+140, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+140
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+140, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+140
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+140
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+140
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+140
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+140
                        , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 230, 140, 140, 140
                    , 140, 140, 140, 0, 0, 140, 140)
                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+230, returnSellCostBuyPrice = returnSellCostBuyPrice+140, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+140
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+140, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+140
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+140
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+140
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+140
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+140;
UPDATE storedetail SET  productquantity = '7', userid = '101', storedetaildate = '2024-12-18 18:15:27' WHERE storedetailid = '16049';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16050', '1', '1', '0', '16820', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '6', '7', '101', '2024-12-18 18:15:27','0','0');
UPDATE client SET  delegateid = 80 where clientid = 1778;
 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 305, 305, 305
                    , 305, 305, 305 ,0, 0, 305, 305)
                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+440, returnSellCostBuyPrice = returnSellCostBuyPrice+305, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+305
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+305, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+305
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+305
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+305
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+305
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+305;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1778, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 305, 305, 305
                    , 305, 305, 305 ,0, 0, 305, 305)
                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+440, returnSellCostBuyPrice = returnSellCostBuyPrice+305, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+305
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+305, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+305
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+305
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+305
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+305
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+305;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -440, -305, -305
                    , -305, -305, -305, -305, -305, -305)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-440, netSellCostBuyPrice = netSellCostBuyPrice+-305
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-305
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-305
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-305
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-305
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-305
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-305
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-305;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762f1f39007a and sellbillId = 16820 and returnsellbillId = 16820
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:45:27";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:15:27", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:15:27', '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-18 14:45:45";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 18:15:45", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:15:45', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762ee9583ec2
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10744,@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-18 17:47:33', '06762ee9583ec2', '10744', '0.00', '1354', '0', '1', '1354.00', '1354', '0', '1354', '1', '2024-12-18 18:15:45', '', '75', '0', 'هاجر شبانة 25', '2', '1', '3', '78', 'هاجر شبانة 25', '5' ,'0','','','','','-1','0','0','0','0','0','1354','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '1354', userid = '75' 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','0.00','1354','0','اضافة فاتورة مبيعات','150114', '1354', '2024-12-18 18:15:45', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1354', '0', null, '0', null, null,'', '0','1','1','1354','1','2024-12-18 17:47:33','0','0');
UPDATE client SET  inUse = 0 where clientid = 10744;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36057;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150114', '5', '16347', '1', '200', '200', '0', '', '1', '2024-12-18 18:15:45', '16347', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36057-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 = 548453;
 INSERT INTO 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-18', 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-18', 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 = '12', userid = '75', storedetaildate = '2024-12-18 18:15:45' WHERE storedetailid = '16346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16347', '1', '1', '1', '150114', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-18 18:15:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35910;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150114', '5', '16297', '1', '580', '580', '0', '', '1', '2024-12-18 18:15:45', '16297', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35910-1,','1','1','0','0','580','580','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 = 548454;
 INSERT INTO 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-18', 580, 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+580, 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-18', 580, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0, 510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, 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 = '93', userid = '75', storedetaildate = '2024-12-18 18:15:45' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '1', '150114', 'اضافة فاتورة مبيعات', 'sellbillController.php', '94', '93', '75', '2024-12-18 18:15:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36019;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07167', '150114', '5', '16349', '1', '540', '540', '0', '', '1', '2024-12-18 18:15:45', '16349', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36019-1,','1','1','0','0','540','540','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail 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 sellbilldetailid = 548455;
 INSERT INTO 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-18', 540, 480, 480
                    , 478, 480, 478, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 480, 478, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+478
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+478
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+478
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 540, 480, 480
                    , 478, 480, 478, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 480, 478, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+478
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+478
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+478
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 18:15:45' WHERE storedetailid = '16348';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16349', '1', '1', '1', '150114', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-18 18:15:45','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', '150114', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 18:15:45', '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', '150114', '17', '10291', '1', '14', '14', '0', '', '1', '2024-12-18 18:15:45', '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 = 78 where clientid = 10744;
 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-18', 1354, 1130, 1130
                    , 1125, 1130, 1125, 1130
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1130, 1122, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1354, sellCostBuyPrice =sellCostBuyPrice+1130
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1130, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1130, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1130
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1130
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1122
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (10744, '2024-12-18', 1354, 1130, 1130
                    , 1125, 1130, 1125, 1130
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1130, 1122, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1354, sellCostBuyPrice =sellCostBuyPrice+1130
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1130, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1130, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1130
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1130
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1122
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1354, 1130, 1130
                    , 1125, 1130, 1125, 1130, 1130, 1122)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1354, netSellCostBuyPrice = netSellCostBuyPrice+1130
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1130
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1125
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1130
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1125
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1130
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1130
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1122;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762ee9583ec2 and sellbillId = 150114 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:45:46";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 18:15:46", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:15:46', '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-18 14:46:35";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:16:35", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:16:35', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:46:59";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 18:16:59", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:16:59', '75', 'showDetail', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150114');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:47:06";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:17:06", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:17:06', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:47:36";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:17:36", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:17:36', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:48:10";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:18:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:18:10', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:48:41";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:18:41", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:18:41', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.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 ('فاطمة جمال ' , '', '', '01128413093', '0', '', '0', '2024-12-18 18:19:40', '104', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-18','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10745', '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 ('10745','0','0','0','إضافة عميل جديد','10745', '0', '2024-12-18 18:19: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 ('فاطمة جمال ', 'فاطمة جمال ', 'فاطمة جمال ', 'فاطمة جمال ', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '104', '0', '2024-12-18 18:19:40');
UPDATE client SET clientname = 'فاطمة جمال ', clientaddress = '', clientphone = '', clientmobile = '01128413093', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-18', 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='12564',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10745';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:49:56";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:19:56", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:19:56', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:51:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:21:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:21:33', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762f4c5b0923
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10745,@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-18 18:13:57', '06762f4c5b0923', '10745', '0.00', '657', '0', '1', '657.00', '657', '0', '657', '1', '2024-12-18 18:21:33', '', '104', '0', 'فاطمة جمال ', '1', '1', '3', '74', 'فاطمة جمال ', '2' ,'0','','','','','-1','0','0','0','0','0','657','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '657', userid = '104' WHERE clientid = '10745';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10745','0.00','657','0','اضافة فاتورة مبيعات','150115', '657', '2024-12-18 18:21:33', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '657', '0', null, '0', null, null,'', '0','1','1','657','1','2024-12-18 18:13:57','0','0');
UPDATE client SET  inUse = 0 where clientid = 10745;
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', '150115', '1', '16277', '1', '650', '650', '0', '', '1', '2024-12-18 18:21:33', '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 = 548458;
 INSERT INTO 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-18', 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-18', 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 = '48', userid = '104', storedetaildate = '2024-12-18 18:21:33' WHERE storedetailid = '16276';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16277', '1', '1', '1', '150115', 'اضافة فاتورة مبيعات', 'sellbillController.php', '49', '48', '104', '2024-12-18 18:21: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 ('0','10291', '150115', '17', '10291', '1', '7', '7', '0', '', '1', '2024-12-18 18:21:33', '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 = 74 where clientid = 10745;
 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-18', 657, 550, 550
                    , 549, 550, 547, 546.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 548, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+657, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10745, '2024-12-18', 657, 550, 550
                    , 549, 550, 547, 546.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 548, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+657, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 657, 550, 550
                    , 549, 550, 547, 546.67, 550, 548)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+657, netSellCostBuyPrice = netSellCostBuyPrice+550
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+550
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+549
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+550
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+547
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+546.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+550
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+548;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762f4c5b0923 and sellbillId = 150115 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:51:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:21:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:21:34', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:51:39";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:21:39", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:21:39', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:53:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:23:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 18:23:02', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:53:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:23:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 18:23:13', '104', 'add', '192.168.1.13', '', '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-18', '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 = '5570',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('5590.00','20', '1', '1', 'إضافة مصروف', '25830', '5570', '2024-12-18 18:23:13', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'جرد', expensesdetails = '', expensesValue = '20.00', expensesdate = '2024-12-18', 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 = '25830';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:53:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:23:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 18:23:13', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:53:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:23:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 18:23:15', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:53:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:23:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:23:19', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:53:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:23:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:23:31', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762f68e94a96
-- ----------------------------------------------------------------------------------------------------

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-18 18:21:34', '06762f68e94a96', '1', '0.00', '0', '0', '1', '1160.00', '1160', '1160', '0', '1', '2024-12-18 18:23:31', '', '104', '0', 'نقدي', '1', '0', '3', '54', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1160','0','','0','0','1160','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150116', '0', '2024-12-18 18:23:31', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1160', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 18:21:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35932;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07123', '150116', '5', '16150', '1', '240', '240', '0', '', '1', '2024-12-18 18:23:31', '16150', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35932-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 184.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 184.00
        , lastbuyprice_withTax = 185, meanbuyprice_withTax = 182, lastbuyprice_withDiscountAndTax = 185
                where sellbilldetailid = 548460;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16150, '2024-12-18', 240, 185, 185
                    , 184, 185, 184, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 185, 182, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+182
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 240, 185, 185
                    , 184, 185, 184, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 185, 182, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+185
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+184
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+184
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+182
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 18:23:31' WHERE storedetailid = '16149';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16150', '1', '1', '1', '150116', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '104', '2024-12-18 18:23:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35962;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0K805', '150116', '7', '16313', '1', '300', '300', '0', '', '1', '2024-12-18 18:23:31', '16313', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35962-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 = 548461;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16313, '2024-12-18', 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-18', 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 = '104', storedetaildate = '2024-12-18 18:23:31' WHERE storedetailid = '16312';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16313', '1', '1', '1', '150116', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-18 18:23:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36083;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07245', '150116', '5', '16363', '1', '620', '620', '0', '', '1', '2024-12-18 18:23:31', '16363', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36083-1,','1','1','0','0','620','620','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 = 575, lastbuyprice_withDiscountAndTax = 575
                where sellbilldetailid = 548462;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16363, '2024-12-18', 620, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 575, 575, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+575
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 620, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0, 575, 575, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+575
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+575, sellCostMeanBuyPrice = sellCostMeanBuyPrice+575
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+575, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+575
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+575
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+575
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+575
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '104', storedetaildate = '2024-12-18 18:23:31' WHERE storedetailid = '16362';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16363', '1', '1', '1', '150116', 'اضافة فاتورة مبيعات', 'sellbillController.php', '75', '74', '104', '2024-12-18 18:23:31','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6730',  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 ('5570','1160', '0', '1', 'اضافة فاتورة مبيعات', '150116', '6730', '2024-12-18 18:23:31', '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-18', 1160, 1000, 1000
                    , 999, 1000, 999, 995
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1000, 997, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1160, sellCostBuyPrice =sellCostBuyPrice+1000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+999
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+999
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+995
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1000
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+997
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1160, 1000, 1000
                    , 999, 1000, 999, 995
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1000, 997, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1160, sellCostBuyPrice =sellCostBuyPrice+1000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+999
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+999
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+995
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1000
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+997
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1160, 1000, 1000
                    , 999, 1000, 999, 995, 1000, 997)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1160, netSellCostBuyPrice = netSellCostBuyPrice+1000
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1000
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+999
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1000
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+999
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+995
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1000
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+997;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762f68e94a96 and sellbillId = 150116 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:53:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:23:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:23:32', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:54:32";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 18:24:32", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:24:32', '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-18 14:54:44";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:24:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:24:44', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247456
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9026,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 18:24:44', userid = '2' WHERE clientid = '9026';
UPDATE client SET  inUse = 0 where clientid = 9026;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9026','1222.00','1222','1','ايصال تحصيل (( قبض من عميل ))','247456', '0', '2024-12-18 17:58:54', '2', 'clientPayedDeptController.php', '   ', '1222', '0', null, '0', null, null,'', '-1','1','1','1222','1','','3538','0');
UPDATE save SET  savecurrentvalue = '251120.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('249898.50','1222', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247464', '251120.5', '2024-12-18 18:24:44', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1222', '1222', '2024-12-18', '2', '0', '0', '2024-12-18 18:24:44','اضافة ايصال سداد للعميل شدن محمد K205','1','0','0','0','247464','clientPayedDeptController.php?do=show&id=247464');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122188', '-1', '1222', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1222', 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 ('122188', '-1', '1222', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1222', 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 = '9026', clientdebtchangebefore = '1222.000', clientdebtchangeamount = '1222.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247456', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 17:58:54', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1222.00',discount='', reciptid='0', dailyentryid = '122188',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1222',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247464';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247456 -clientdebtchangeId = 247464
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:54:45";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:24:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:24: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-18 14:54:51";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:24:51", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:24:51', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:55:02";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:25:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:25:03', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247465
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5780,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '45' , clientdate = '2024-12-18 18:25:03', userid = '2' WHERE clientid = '5780';
UPDATE client SET  inUse = 0 where clientid = 5780;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5780','2455.00','2410','1','ايصال تحصيل (( قبض من عميل ))','247465', '45', '2024-12-18 18:24:45', '2', 'clientPayedDeptController.php', '   ', '2410', '0', null, '0', null, null,'', '-1','1','1','2410','1','','3539','0');
UPDATE save SET  savecurrentvalue = '253530.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('251120.50','2410', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247465', '253530.5', '2024-12-18 18:25:03', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '2410', '2410', '2024-12-18', '2', '0', '0', '2024-12-18 18:25:03','اضافة ايصال سداد للعميل اية حسين كفر الدوار 58','1','0','0','0','247465','clientPayedDeptController.php?do=show&id=247465');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122189', '-1', '2410', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '2410', 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 ('122189', '-1', '2410', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-2410', 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 = '5780', clientdebtchangebefore = '2455.000', clientdebtchangeamount = '2410.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247465', clientdebtchangeafter = '45.000', clientdebtchangedate = '2024-12-18 18:24:45', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '2410.00',discount='', reciptid='0', dailyentryid = '122189',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='2410',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247465';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:55:03";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:25:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:25: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-18 14:55:12";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 18:25:13", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:25:13', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762f740c4f08
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(220,@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-18 18:24:32', '06762f740c4f08', '220', '0.00', '444', '0', '1', '444.00', '444', '0', '444', '1', '2024-12-18 18:25:13', '', '75', '0', 'دعاء عثمان Y338', '2', '1', '3', '80', 'دعاء عثمان Y338', '4' ,'0','','','','','-1','0','0','0','0','0','444','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '444', userid = '75' WHERE clientid = '220';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('220','0.00','444','0','اضافة فاتورة مبيعات','150117', '444', '2024-12-18 18:25:13', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '444', '0', null, '0', null, null,'', '0','1','1','444','1','2024-12-18 18:24:32','0','0');
UPDATE client SET  inUse = 0 where clientid = 220;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '150117', '5', '15855', '2', '210', '420', '0', '', '1', '2024-12-18 18:25:13', '15855', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36187-2,','1','1','0','0','210','420','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 = 548463;
 INSERT INTO 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-18', 420, 290, 290
                    , 290, 290, 290, 290
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 290, 290, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+290
                            , 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
                        , 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-18', 420, 290, 290
                    , 290, 290, 290, 290
                    , 0, 0, 0, 0
                    , 0, 0, 0, 290, 290, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+290
                            , 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;
UPDATE storedetail SET  productquantity = '22', userid = '75', storedetaildate = '2024-12-18 18:25:13' WHERE storedetailid = '15854';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15855', '1', '2', '1', '150117', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '22', '75', '2024-12-18 18:25: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', '150117', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 18:25: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', '150117', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-18 18:25:13', '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 = 80 where clientid = 220;
 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-18', 444, 290, 290
                    , 290, 290, 290, 290
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,290, 290, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+444, sellCostBuyPrice =sellCostBuyPrice+290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+290
                            , 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 (220, '2024-12-18', 444, 290, 290
                    , 290, 290, 290, 290
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,290, 290, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+444, sellCostBuyPrice =sellCostBuyPrice+290
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+290, sellCostMeanBuyPrice = sellCostMeanBuyPrice+290
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+290, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+290
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+290
                            , 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, 444, 290, 290
                    , 290, 290, 290, 290, 290, 290)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+444, netSellCostBuyPrice = netSellCostBuyPrice+290
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+290
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+290
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+290
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+290
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+290
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+290
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+290;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762f740c4f08 and sellbillId = 150117 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:55:13";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 18:25:13", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:25: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 ('7331','','5','170','230', '230','230', '2024-12-18', '0', '77', '1', '07331', '0', '0', '0', '0', '0', '170','170','170','170','170','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','170','170','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16495, 1,'2024-12-18 18:26:16',77)
                ON DUPLICATE KEY UPDATE productid = 16495, edited = 1, sysdate = '2024-12-18 18:26: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', '16495', '1', '2024-12-18', '77', '0','1649501','230','230','230','170','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16495', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16495', '1', '0', '0', '16495', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:56:48";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 18:26:48", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:26:48', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762f769f32ef
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6579,@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-18 18:25:14', '06762f769f32ef', '6579', '0.00', '263', '0', '1', '263.00', '263', '0', '263', '1', '2024-12-18 18:26:48', '', '75', '0', 'راندا سعد I655', '2', '1', '3', '81', 'راندا سعد I655', '4' ,'0','','','','','-1','0','0','0','0','0','263','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '263', userid = '75' WHERE clientid = '6579';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6579','0.00','263','0','اضافة فاتورة مبيعات','150118', '263', '2024-12-18 18:26:48', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '263', '0', null, '0', null, null,'', '0','1','1','263','1','2024-12-18 18:25:14','0','0');
UPDATE client SET  inUse = 0 where clientid = 6579;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35775;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2932', '150118', '1', '14437', '1', '185', '185', '0', '', '1', '2024-12-18 18:26:48', '14437', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35775-1,','1','1','0','0','185','185','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 = 550, lastbuyprice_withDiscountAndTax = 220
                where sellbilldetailid = 548466;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14437, '2024-12-18', 185, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 220, 550, 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+220
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 185, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 550, 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+220
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 18:26:48' WHERE storedetailid = '14436';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14437', '1', '1', '1', '150118', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-18 18:26: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 ('60','عرض 60', '150118', '18', '10343', '1', '55', '55', '0', '', '1', '2024-12-18 18:26:48', '10343', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','55','55','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 = 548467;
 INSERT INTO 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-18', 55, 60, 60
                    , 60, 60, 60, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+55, sellCostBuyPrice =sellCostBuyPrice+60
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+60, sellCostMeanBuyPrice = sellCostMeanBuyPrice+60
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+60, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+60
                            , 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-18', 55, 60, 60
                    , 60, 60, 60, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+55, sellCostBuyPrice =sellCostBuyPrice+60
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+60, sellCostMeanBuyPrice = sellCostMeanBuyPrice+60
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+60, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+60
                            , 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 = '-14', userid = '75', storedetaildate = '2024-12-18 18:26:48' WHERE storedetailid = '10342';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10343', '1', '1', '1', '150118', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-13', '-14', '75', '2024-12-18 18:26: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', '150118', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 18:26: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', '150118', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-18 18:26:49', '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 = 81 where clientid = 6579;
 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-18', 263, 280, 280
                    , 280, 280, 280, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,220, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+263, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+220
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (6579, '2024-12-18', 263, 280, 280
                    , 280, 280, 280, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,220, 550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+263, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+220
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 263, 280, 280
                    , 280, 280, 280, 220, 220, 550)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+263, netSellCostBuyPrice = netSellCostBuyPrice+280
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+280
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+280
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+220
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+220
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+550;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762f769f32ef and sellbillId = 150118 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:56:49";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-18 18:26:49", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:26:49', '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-18 14:56:54";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:26:54", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 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 =247466
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10626,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '500' , clientdate = '2024-12-18 18:26:54', 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','1877.00','1377','1','ايصال تحصيل (( قبض من عميل ))','247466', '500', '2024-12-18 18:25:03', '2', 'clientPayedDeptController.php', '   ', '1377', '0', null, '0', null, null,'', '-1','1','1','1377','1','','3540','0');
UPDATE save SET  savecurrentvalue = '254907.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('253530.50','1377', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247468', '254907.5', '2024-12-18 18:26:54', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1377', '1377', '2024-12-18', '2', '0', '0', '2024-12-18 18:26:55','اضافة ايصال سداد للعميل هند محمد فريد','1','0','0','0','247468','clientPayedDeptController.php?do=show&id=247468');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122190', '-1', '1377', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1377', 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 ('122190', '12292', '1377', '','0');
UPDATE accountstree SET name = 'هند محمد فريد', customName = 'هند محمد فريد', customNameEn = 'هند محمد فريد', nameEn = 'هند محمد فريد', parent = '58', accountNature = '0', theValue = '-7437', 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 = '1877.000', clientdebtchangeamount = '1377.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247466', clientdebtchangeafter = '500.000', clientdebtchangedate = '2024-12-18 18:25:03', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1377.00',discount='', reciptid='0', dailyentryid = '122190',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1377',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247468';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247466 -clientdebtchangeId = 247468
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:56:55";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:26:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 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-18 14:57:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:27:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:27:18', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762f7048212b
-- ----------------------------------------------------------------------------------------------------

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-18 18:23:32', '06762f7048212b', '1', '0.00', '0', '0', '1', '740.00', '740', '740', '0', '1', '2024-12-18 18:27:19', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','740','0','','0','0','740','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150119', '0', '2024-12-18 18:27:19', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '740', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 18:23:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34594;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06841', '150119', '5', '15569', '1', '155', '155', '0', '', '1', '2024-12-18 18:27:19', '15569', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34594-1,','1','1','0','0','155','155','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 = 106, lastbuyprice_withDiscountAndTax = 170
                where sellbilldetailid = 548470;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15569, '2024-12-18', 155, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 170, 106, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+106
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 155, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 106, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+106
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 18:27:19' WHERE storedetailid = '15568';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15569', '1', '1', '1', '150119', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-18 18:27:19','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 ('400','B1293', '150119', '2', '14101', '1', '165', '165', '0', '', '1', '2024-12-18 18:27:19', '14101', '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 = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        
                where sellbilldetailid = 548471;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14101, '2024-12-18', 165, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 165, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+400
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 18:27:19' WHERE storedetailid = '14100';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14101', '1', '1', '1', '150119', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-18 18:27:19','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', '150119', '14', '16404', '1', '420', '420', '0', '', '1', '2024-12-18 18:27:19', '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 = 548472;
 INSERT INTO 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-18', 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-18', 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 = '18', userid = '104', storedetaildate = '2024-12-18 18:27:19' WHERE storedetailid = '16403';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16404', '1', '1', '1', '150119', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '104', '2024-12-18 18:27:19','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '7470',  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 ('6730','740', '0', '1', 'اضافة فاتورة مبيعات', '150119', '7470', '2024-12-18 18:27:19', '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-18', 740, 910, 910
                    , 910, 910, 910, 910
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,510, 446, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+740, sellCostBuyPrice =sellCostBuyPrice+910
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+910, sellCostMeanBuyPrice = sellCostMeanBuyPrice+910
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+910, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+910
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+910
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+510
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+446
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 740, 910, 910
                    , 910, 910, 910, 910
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,510, 446, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+740, sellCostBuyPrice =sellCostBuyPrice+910
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+910, sellCostMeanBuyPrice = sellCostMeanBuyPrice+910
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+910, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+910
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+910
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+510
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+446
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 740, 910, 910
                    , 910, 910, 910, 910, 510, 446)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+740, netSellCostBuyPrice = netSellCostBuyPrice+910
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+910
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+910
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+910
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+910
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+910
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+510
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+446;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762f7048212b and sellbillId = 150119 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247469
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10626,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 18:27:22', 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','500.00','500','1','ايصال تحصيل (( قبض من عميل ))','247469', '0', '2024-12-18 18:26:55', '2', 'clientPayedDeptController.php', '   ', '500', '0', null, '0', null, null,'', '-1','1','1','500','1','','3541','0');
UPDATE save SET  savecurrentvalue = '255407.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('254907.50','500', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247470', '255407.5', '2024-12-18 18:27:22', '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-18', '2', '0', '0', '2024-12-18 18:27:22','اضافة ايصال سداد للعميل هند محمد فريد','1','0','0','0','247470','clientPayedDeptController.php?do=show&id=247470');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122191', '-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 ('122191', '12292', '500', '','0');
UPDATE accountstree SET name = 'هند محمد فريد', customName = 'هند محمد فريد', customNameEn = 'هند محمد فريد', nameEn = 'هند محمد فريد', parent = '58', accountNature = '0', theValue = '-7937', 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 = '500.000', clientdebtchangeamount = '500.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247469', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 18:26:55', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '500.00',discount='', reciptid='0', dailyentryid = '122191',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='500',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247470';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247469 -clientdebtchangeId = 247470
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:57:23";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:27:23", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:27:23', '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 ('7336','','5','170','230', '230','230', '2024-12-18', '0', '77', '1', '07336', '0', '0', '0', '0', '0', '170','170','170','170','170','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','170','170','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16496, 1,'2024-12-18 18:27:34',77)
                ON DUPLICATE KEY UPDATE productid = 16496, edited = 1, sysdate = '2024-12-18 18:27: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', '16496', '1', '2024-12-18', '77', '0','1649601','230','230','230','170','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16496', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16496', '1', '0', '0', '16496', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:57:40";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:27:40", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:27:40', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247471
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10745,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 18:27:40', userid = '2' WHERE clientid = '10745';
UPDATE client SET  inUse = 0 where clientid = 10745;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10745','657.00','657','1','ايصال تحصيل (( قبض من عميل ))','247471', '0', '2024-12-18 18:27:23', '2', 'clientPayedDeptController.php', '   ', '657', '0', null, '0', null, null,'', '-1','1','1','657','1','','3542','0');
UPDATE save SET  savecurrentvalue = '256064.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('255407.50','657', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247471', '256064.5', '2024-12-18 18:27:40', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '657', '657', '2024-12-18', '2', '0', '0', '2024-12-18 18:27:40','اضافة ايصال سداد للعميل فاطمة جمال ','1','0','0','0','247471','clientPayedDeptController.php?do=show&id=247471');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122192', '-1', '657', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '657', 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 ('122192', '12564', '657', '','0');
UPDATE accountstree SET name = 'فاطمة جمال ', customName = 'فاطمة جمال ', customNameEn = 'فاطمة جمال ', nameEn = 'فاطمة جمال ', parent = '58', accountNature = '0', theValue = '-657', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '104', del = '0', sysdate = '2024-12-18 18:19:40' WHERE id = '12564';
UPDATE clientdebtchange SET clientid = '10745', clientdebtchangebefore = '657.000', clientdebtchangeamount = '657.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247471', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 18:27:23', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '657.00',discount='', reciptid='0', dailyentryid = '122192',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='657',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247471';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:57:41";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:27:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:27:41', '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 ('7337','','5','540','630', '630','630', '2024-12-18', '0', '77', '1', '07337', '0', '0', '0', '0', '0', '540','540','540','540','540','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','540','540','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16497, 1,'2024-12-18 18:27:51',77)
                ON DUPLICATE KEY UPDATE productid = 16497, edited = 1, sysdate = '2024-12-18 18:27: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', '16497', '1', '2024-12-18', '77', '0','1649701','630','630','630','540','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16497', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16497', '1', '0', '0', '16497', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:58:37";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:28:37", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:28:37', '77', 'add', '192.168.1.21', '', '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 ('06762f62ce29bc', '2024-12-18 18:19:56', '13', '75685.00', '87910', '0', '0', '12225',  '12225', '0', '12225', '1', '2024-12-18 18:28:37', '', '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 ('07331', '14149', '5', '16495', '15', '170', '2550', '0', '', '2024-12-18 18:28:37', '16495','','','0','0','0','0','0',null,'170','2550','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-18 18:19:56', 1, 16495, 0, 0
                    , 170, 15, 0, 0, 77, '2024-12-18 18:28:37')
                ON DUPLICATE KEY UPDATE buyprice = 170,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:28:37' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16495', '170', '15', '0', 'buyBillController.php', '32747', '', '0', '0');
UPDATE product SET  productBuyPrice = "170" WHERE productId = 16495 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32747 ;
UPDATE product SET productName = '7331', productDescription = '', productCatId = '5', productBuyPrice = '170.00', productSellAllPrice = '230.00', productSellUnitPrice = '230.00', productSellHalfPrice = '230.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07331',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '170',lastbuyprice_withDiscount = '170',meanbuyprice = '170',meanbuyprice_withDiscount = '170' , productbuypricereal = '170.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='170',meanbuyprice_withTax='170',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='170'  WHERE productId = '16495';
UPDATE buybilldetail SET  lastbuyprice = 170 , meanbuyprice = 170, lastbuyprice_withDiscount = 170, meanbuyprice_withDiscount = 170
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where buybilldetailid = 32747;
UPDATE productunit SET proUnitBuyPrice  = 170 * productnumber WHERE productid = 16495;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16494';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16495', '1', '15', '0', '14149', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 18:19: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 ('07336', '14149', '5', '16496', '15', '170', '2550', '0', '', '2024-12-18 18:28:37', '16496','','','0','0','0','0','0',null,'170','2550','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-18 18:19:56', 1, 16496, 0, 0
                    , 170, 15, 0, 0, 77, '2024-12-18 18:28:37')
                ON DUPLICATE KEY UPDATE buyprice = 170,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:28:37' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16496', '170', '15', '0', 'buyBillController.php', '32748', '', '0', '0');
UPDATE product SET  productBuyPrice = "170" WHERE productId = 16496 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32748 ;
UPDATE product SET productName = '7336', productDescription = '', productCatId = '5', productBuyPrice = '170.00', productSellAllPrice = '230.00', productSellUnitPrice = '230.00', productSellHalfPrice = '230.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07336',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '170',lastbuyprice_withDiscount = '170',meanbuyprice = '170',meanbuyprice_withDiscount = '170' , productbuypricereal = '170.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='170',meanbuyprice_withTax='170',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='170'  WHERE productId = '16496';
UPDATE buybilldetail SET  lastbuyprice = 170 , meanbuyprice = 170, lastbuyprice_withDiscount = 170, meanbuyprice_withDiscount = 170
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where buybilldetailid = 32748;
UPDATE productunit SET proUnitBuyPrice  = 170 * productnumber WHERE productid = 16496;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16495';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16496', '1', '15', '0', '14149', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 18:19: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 ('07337', '14149', '5', '16497', '10', '540', '5400', '0', '', '2024-12-18 18:28:37', '16497','','','0','0','0','0','0',null,'540','5400','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-18 18:19:56', 1, 16497, 0, 0
                    , 540, 10, 0, 0, 77, '2024-12-18 18:28:37')
                ON DUPLICATE KEY UPDATE buyprice = 540,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:28:37' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16497', '540', '10', '0', 'buyBillController.php', '32749', '', '0', '0');
UPDATE product SET  productBuyPrice = "540" WHERE productId = 16497 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32749 ;
UPDATE product SET productName = '7337', productDescription = '', productCatId = '5', productBuyPrice = '540.00', productSellAllPrice = '630.00', productSellUnitPrice = '630.00', productSellHalfPrice = '630.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07337',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '540',lastbuyprice_withDiscount = '540',meanbuyprice = '540',meanbuyprice_withDiscount = '540' , productbuypricereal = '540.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='540',meanbuyprice_withTax='540',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='540'  WHERE productId = '16497';
UPDATE buybilldetail SET  lastbuyprice = 540 , meanbuyprice = 540, lastbuyprice_withDiscount = 540, meanbuyprice_withDiscount = 540
        , lastbuyprice_withTax = 540, meanbuyprice_withTax = 540, lastbuyprice_withDiscountAndTax = 540
                where buybilldetailid = 32749;
UPDATE productunit SET proUnitBuyPrice  = 540 * productnumber WHERE productid = 16497;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16496';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16497', '1', '10', '0', '14149', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-18 18:19: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 ('R3322', '14149', '1', '16265', '15', '115', '1725', '0', '', '2024-12-18 18:28:37', '16265','','','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-18 18:19:56', 1, 16265, 0, 0
                    , 115, 15, 0, 0, 77, '2024-12-18 18:28:37')
                ON DUPLICATE KEY UPDATE buyprice = 115,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:28:37' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16265', '115', '15', '0', 'buyBillController.php', '32750', '', '0', '0');
UPDATE product SET  productBuyPrice = "115" WHERE productId = 16265 ;
UPDATE buybilldetail SET  quantitybefore = 5 WHERE buybilldetailid = 32750 ;
UPDATE product SET productName = 'R3322', productDescription = '', productCatId = '1', productBuyPrice = '115.00', productSellAllPrice = '165.00', productSellUnitPrice = '165.00', productSellHalfPrice = '165.00', productDate = '2024-12-05', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3322',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='115',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 = '16265';
UPDATE buybilldetail SET  lastbuyprice = 115 , meanbuyprice = 115, lastbuyprice_withDiscount = 115, meanbuyprice_withDiscount = 115
        , lastbuyprice_withTax = 115, meanbuyprice_withTax = 115, lastbuyprice_withDiscountAndTax = 115
                where buybilldetailid = 32750;
UPDATE productunit SET proUnitBuyPrice  = 115 * productnumber WHERE productid = 16265;
UPDATE storedetail SET  productquantity = '20', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16264';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16265', '1', '15', '0', '14149', 'اضافة فاتورة مشتريات', 'buyBillController.php', '5', '20', '77', '2024-12-18 18:19:56','0','0');
UPDATE supplier SET  suppliercurrentDebt = '87910',suppliercurrentDebtInCurrency= '87910' , userid = '77', supplierdate = '2024-12-18 18:28:37'   WHERE supplierid = '13';
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 ('13', '75685.00', '12225', '0', 'اضافة فاتورة مشتريات', '14149', '87910', '2024-12-18 18:19:56', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','12225','1','75685','12225','87910','0');
update buybill set dailyentryid='0,' where buybillid=14149;
COMMIT;
UPDATE product SET overAllAveragePrice = 115 WHERE productId = 16265;UPDATE product SET overAllAveragePrice = 170 WHERE productId = 16495;UPDATE product SET overAllAveragePrice = 170 WHERE productId = 16496;UPDATE product SET overAllAveragePrice = 540 WHERE productId = 16497;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:58:37";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:28:37", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:28:37', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14149');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:59:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:29:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:29:14', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762f7e7daa09
-- ----------------------------------------------------------------------------------------------------

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-18 18:27:19', '06762f7e7daa09', '1', '0.00', '0', '0', '1', '1350.00', '1350', '1350', '0', '1', '2024-12-18 18:29:14', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1350','0','','0','0','1350','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150120', '0', '2024-12-18 18:29:14', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1350', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 18:27:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36095;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07255', '150120', '5', '16369', '1', '260', '260', '0', '', '1', '2024-12-18 18:29:14', '16369', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36095-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 = 548473;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16369, '2024-12-18', 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-18', 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 = '35', userid = '104', storedetaildate = '2024-12-18 18:29:14' WHERE storedetailid = '16368';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16369', '1', '1', '1', '150120', 'اضافة فاتورة مبيعات', 'sellbillController.php', '36', '35', '104', '2024-12-18 18:29:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34434;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3205', '150120', '1', '15411', '1', '620', '620', '0', '', '1', '2024-12-18 18:29:14', '15411', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34434-1,','1','1','0','0','620','620','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 = 548474;
 INSERT INTO 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-18', 620, 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+620, 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-18', 620, 550, 550
                    , 548, 550, 548, 502.35
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 471, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, 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 = '90', userid = '104', storedetaildate = '2024-12-18 18:29:14' WHERE storedetailid = '15410';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15411', '1', '1', '1', '150120', 'اضافة فاتورة مبيعات', 'sellbillController.php', '91', '90', '104', '2024-12-18 18:29:14','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', '150120', '1', '16410', '1', '470', '470', '0', '', '1', '2024-12-18 18:29:14', '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 = 548475;
 INSERT INTO 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-18', 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-18', 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 = '8', userid = '104', storedetaildate = '2024-12-18 18:29:14' WHERE storedetailid = '16409';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16410', '1', '1', '1', '150120', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-18 18:29:14','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '8820',  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 ('7470','1350', '0', '1', 'اضافة فاتورة مبيعات', '150120', '8820', '2024-12-18 18:29:14', '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-18', 1350, 1170, 1170
                    , 1168, 1170, 1168, 1122.35
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1170, 1091, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1350, sellCostBuyPrice =sellCostBuyPrice+1170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1168
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1168
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1122.35
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1091
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1350, 1170, 1170
                    , 1168, 1170, 1168, 1122.35
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1170, 1091, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1350, sellCostBuyPrice =sellCostBuyPrice+1170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1168
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1168
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1122.35
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1091
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1350, 1170, 1170
                    , 1168, 1170, 1168, 1122.35, 1170, 1091)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1350, netSellCostBuyPrice = netSellCostBuyPrice+1170
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1170
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1168
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1170
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1168
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1122.35
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1170
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1091;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762f7e7daa09 and sellbillId = 150120 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 14:59:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:29:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:29:15', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:00:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:30:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:30:45', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762f85bac35c
-- ----------------------------------------------------------------------------------------------------

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-18 18:29:15', '06762f85bac35c', '1', '0.00', '0', '0', '1', '810.00', '810', '810', '0', '1', '2024-12-18 18:30:46', '', '104', '0', 'نقدي', '1', '0', '3', '26', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','810','0','','0','0','810','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150121', '0', '2024-12-18 18:30:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '810', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 18:29:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35968;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150121', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-18 18:30:46', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35968-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 = 548476;
 INSERT INTO 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-18', 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-18', 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 = '48', userid = '104', storedetaildate = '2024-12-18 18:30:46' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '150121', 'اضافة فاتورة مبيعات', 'sellbillController.php', '49', '48', '104', '2024-12-18 18:30:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '9630',  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 ('8820','810', '0', '1', 'اضافة فاتورة مبيعات', '150121', '9630', '2024-12-18 18:30:46', '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-18', 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;
 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-18', 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;
 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 06762f85bac35c and sellbillId = 150121 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247472
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1642,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 18:33:24', userid = '2' WHERE clientid = '1642';
UPDATE client SET  inUse = 0 where clientid = 1642;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1642','273.00','273','1','ايصال تحصيل (( قبض من عميل ))','247472', '0', '2024-12-18 18:27:41', '2', 'clientPayedDeptController.php', '   ', '273', '0', null, '0', null, null,'', '-1','1','1','273','1','','3543','0');
UPDATE save SET  savecurrentvalue = '256337.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('256064.50','273', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247474', '256337.5', '2024-12-18 18:33:24', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '273', '273', '2024-12-18', '2', '0', '0', '2024-12-18 18:33:24','اضافة ايصال سداد للعميل مايسة الجوهري y112','1','0','0','0','247474','clientPayedDeptController.php?do=show&id=247474');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122193', '-1', '273', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '273', 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 ('122193', '-1', '273', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-273', 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 = '1642', clientdebtchangebefore = '273.000', clientdebtchangeamount = '273.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247472', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 18:27:41', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '273.00',discount='', reciptid='0', dailyentryid = '122193',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='273',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247474';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247472 -clientdebtchangeId = 247474
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:03:24";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:33:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:33: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-18 15:03:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:33:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:33:38', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762f8b6d62d6
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1412,@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-18 18:30:46', '06762f8b6d62d6', '1412', '-2.00', '604', '0', '1', '606.00', '606', '0', '606', '1', '2024-12-18 18:33:38', '', '104', '0', 'مدام ريهام 73', '1', '1', '3', '4', 'مدام ريهام 73', '3' ,'0','','','','','-1','0','0','0','0','0','606','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '604', userid = '104' WHERE clientid = '1412';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1412','-2.00','606','0','اضافة فاتورة مبيعات','150122', '604', '2024-12-18 18:33:38', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '606', '0', null, '0', null, null,'', '0','1','1','606','1','2024-12-18 18:30:46','0','0');
UPDATE client SET  inUse = 0 where clientid = 1412;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36296;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07043', '150122', '5', '16022', '1', '200', '200', '0', '', '1', '2024-12-18 18:33:38', '16022', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36296-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 = 548477;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16022, '2024-12-18', 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-18', 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 = '6', userid = '104', storedetaildate = '2024-12-18 18:33:38' WHERE storedetailid = '16021';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16022', '1', '1', '1', '150122', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-18 18:33:38','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', '150122', '5', '15539', '1', '400', '400', '0', '', '1', '2024-12-18 18:33:38', '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 = 548478;
 INSERT INTO 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-18', 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-18', 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 = '25', userid = '104', storedetaildate = '2024-12-18 18:33:38' WHERE storedetailid = '15538';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15539', '1', '1', '1', '150122', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '104', '2024-12-18 18:33: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', '150122', '17', '10291', '1', '6', '6', '0', '', '1', '2024-12-18 18:33:38', '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 = 4 where clientid = 1412;
 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-18', 606, 485, 485
                    , 491, 485, 491, 491.25
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,485, 498, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+606, sellCostBuyPrice =sellCostBuyPrice+485
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+485, sellCostMeanBuyPrice = sellCostMeanBuyPrice+491
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+485, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+491
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+491.25
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+485
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+498
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (1412, '2024-12-18', 606, 485, 485
                    , 491, 485, 491, 491.25
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,485, 498, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+606, sellCostBuyPrice =sellCostBuyPrice+485
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+485, sellCostMeanBuyPrice = sellCostMeanBuyPrice+491
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+485, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+491
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+491.25
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+485
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+498
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 606, 485, 485
                    , 491, 485, 491, 491.25, 485, 498)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+606, netSellCostBuyPrice = netSellCostBuyPrice+485
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+485
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+491
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+485
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+491
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+491.25
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+485
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+498;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762f8b6d62d6 and sellbillId = 150122 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:03:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:33:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:33:39', '104', 'addsellBill', '192.168.1.13', '', '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 ('H1687','','14','400','500', '500','500', '2024-12-18', '0', '77', '1', 'H1687', '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 (16498, 1,'2024-12-18 18:35:40',77)
                ON DUPLICATE KEY UPDATE productid = 16498, edited = 1, sysdate = '2024-12-18 18:35: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', '16498', '1', '2024-12-18', '77', '0','1649801','500','500','500','400','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16498', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16498', '1', '0', '0', '16498', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:05:47";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:35:47", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:35:47', '77', 'add', '192.168.1.21', '', '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 ('06762f7535867e', '2024-12-18 18:24:51', '9', '292950.00', '300950', '0', '0', '8000',  '8000', '0', '8000', '1', '2024-12-18 18:35:47', '', '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 ('H1687', '14150', '14', '16498', '20', '400', '8000', '0', '', '2024-12-18 18:35:47', '16498','','','0','0','0','0','0',null,'400','8000','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-18 18:24:51', 1, 16498, 0, 0
                    , 400, 20, 0, 0, 77, '2024-12-18 18:35:47')
                ON DUPLICATE KEY UPDATE buyprice = 400,
                        buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:35:47' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16498', '400', '20', '0', 'buyBillController.php', '32751', '', '0', '0');
UPDATE product SET  productBuyPrice = "400" WHERE productId = 16498 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32751 ;
UPDATE product SET productName = 'H1687', productDescription = '', productCatId = '14', productBuyPrice = '400.00', productSellAllPrice = '500.00', productSellUnitPrice = '500.00', productSellHalfPrice = '500.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1687',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 = '16498';
UPDATE buybilldetail SET  lastbuyprice = 400 , meanbuyprice = 400, lastbuyprice_withDiscount = 400, meanbuyprice_withDiscount = 400
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where buybilldetailid = 32751;
UPDATE productunit SET proUnitBuyPrice  = 400 * productnumber WHERE productid = 16498;
UPDATE storedetail SET  productquantity = '20', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16497';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16498', '1', '20', '0', '14150', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '20', '77', '2024-12-18 18:24:51','0','0');
UPDATE supplier SET  suppliercurrentDebt = '300950',suppliercurrentDebtInCurrency= '300950' , userid = '77', supplierdate = '2024-12-18 18:35:47'   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', '292950.00', '8000', '0', 'اضافة فاتورة مشتريات', '14150', '300950', '2024-12-18 18:24:51', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','8000','1','292950','8000','300950','0');
update buybill set dailyentryid='0,' where buybillid=14150;
COMMIT;
UPDATE product SET overAllAveragePrice = 400 WHERE productId = 16498;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:05:48";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:35:48", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:35:48', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14150');
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-18 15:06:10";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 18:36:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 18:36: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-18 15:06:11";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:06:11";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 18:36:11", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 18:36:11', '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-18 15:06:12";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:06:17";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 18:36:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-18 18:36: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-18 15:06:24";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 18:36:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-18 18:36: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-18 15:06:39";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:36:39", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 18:36:39', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:06:41";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:36:41", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:36:41', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:07:42";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:37:42", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 18:37:42', '77', 'oneSupplier', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:07:57";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:37:57", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 18:37:57', '77', 'oneSupplier', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:08:00";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:38:00", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:38:00', '77', 'details', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=details&id=14131');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:08:13";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:38:13", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:38:13', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:08:23";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:38:23", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 18:38:23', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14131&type=2&parcodeTypeToPrint=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:08:29";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:38:29", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:38:29', '77', 'editbill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editbill&id=14131');
UPDATE productunit SET unitid = '1', productid = '16473', productnumber = '1.00', productunitdate = '2024-12-18', userid = '77', conditions = '0',proUnitParcode='1647301',proUnitSellAllPrice='450',proUnitSellHalfPrice='450',proUnitSellUnitPrice ='450',proUnitBuyPrice='370',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16473';
UPDATE product SET productName = 'H1689', productDescription = '', productCatId = '14', productBuyPrice = '300', productSellAllPrice = '450', productSellUnitPrice = '450', productSellHalfPrice = '450', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1689',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '370.00',lastbuyprice_withDiscount = '370',meanbuyprice = '335',meanbuyprice_withDiscount = '335' , productbuypricereal = '370' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='370',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='370',meanbuyprice_withTax='370',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='370'  WHERE productId = '16473';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:08:49";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:38:49", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:38:49', '77', 'update', '192.168.1.21', '', '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 = 14131;
UPDATE buybill SET  buybillsysdate = '2024-12-18 18:38:49', userid = '77',delbyuserid = '77', conditions = '1' WHERE buybillid = '14131';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-18 15:21:56', 1, 16473, 0, 0
                    , 370, 10, 0, 0, 77, '2024-12-18 18:38:50')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-10, sellQuantity = sellQuantity-0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:38:50' ;
UPDATE buybilldetail SET  lastbuyprice = 370.00 , meanbuyprice = 335.00, lastbuyprice_withDiscount = 370.00, meanbuyprice_withDiscount = 335.00
        , lastbuyprice_withTax = 370.00, meanbuyprice_withTax = 370.00, lastbuyprice_withDiscountAndTax = 370.00
                where buybilldetailid = 32697;
UPDATE product SET productName = 'H1689', productDescription = '', productCatId = '14', productBuyPrice = '300.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1689',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '370',lastbuyprice_withDiscount = '0',meanbuyprice = '300.00',meanbuyprice_withDiscount = '300' , productbuypricereal = '370.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='370',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='370',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 = '16473';
UPDATE productunit SET proUnitBuyPrice  = 370 * productnumber WHERE productid = 16473;
UPDATE storedetail SET  productquantity = '0', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16472';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16473', '1', '10', '1', '14131', 'حذف فاتورة مشتريات - للتعديل', 'buyBillController.php', '10', '0', '77', '2024-12-18 15:21:56','0','0');
UPDATE supplier SET  suppliercurrentDebt = '297250',suppliercurrentDebtInCurrency= '297250' , userid = '77', supplierdate = '2024-12-18 18:38:49'   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', '300950.00', '3700.00', '1', 'حذف فاتورة مشتريات - للتعديل', '14131', '297250', '2024-12-18 15:21:56', '77', 'buyBillController.php', 'حذف فاتورة مشتريات - للتعديل', '0','', '0','1','1','3700','1','300950','3700','297250','0');
UPDATE productserial SET del = 1
		 WHERE billid = 14131;
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 ('06762cc743ae55', '2024-12-18 15:23:49', '9', '297250.00', '298750', '0', '0', '1500', '1500', '0.00', '1500', '1', '2024-12-18 18:38:49', '', '77', '0', '', '1', '1','1','14131','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 ('H1689', '14151', '14', '16473', '5', '300', '1500', '0.00', '', '2024-12-18 18:38:49', '16473','','','0','0','0','0','0',null,'300','1500','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-18 15:23:49', 1, 16473, 0, 0
                    , 300, 5, 0, 0, 77, '2024-12-18 18:38:50')
                ON DUPLICATE KEY UPDATE buyprice = 300,
                        buyQuantity =buyQuantity+5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:38:50' ;
UPDATE product SET  productBuyPrice = "300" WHERE productId = 16473 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32752 ;
UPDATE product SET productName = 'H1689', productDescription = '', productCatId = '14', productBuyPrice = '300.00', productSellAllPrice = '450.00', productSellUnitPrice = '450.00', productSellHalfPrice = '450.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1689',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '300',lastbuyprice_withDiscount = '300',meanbuyprice = '300',meanbuyprice_withDiscount = '300' , productbuypricereal = '370.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='370',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='100',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 = '16473';
UPDATE buybilldetail SET  lastbuyprice = 300 , meanbuyprice = 300, lastbuyprice_withDiscount = 300, meanbuyprice_withDiscount = 300
        , lastbuyprice_withTax = 300, meanbuyprice_withTax = 100, lastbuyprice_withDiscountAndTax = 300
                where buybilldetailid = 32752;
UPDATE productunit SET proUnitBuyPrice  = 300 * productnumber WHERE productid = 16473;
UPDATE storedetail SET  productquantity = '5', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16472';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16473', '1', '5', '0', '14151', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '5', '77', '2024-12-18 15:23:49','0','0');
DELETE FROM productserial WHERE billid = 14131
		and type =0 
		;
UPDATE supplier SET  suppliercurrentDebt = '298750',suppliercurrentDebtInCurrency= '298750' , userid = '77', supplierdate = '2024-12-18 18:38:49'   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', '297250.00', '1500', '0', 'اضافة فاتورة مشتريات', '14151', '298750', '2024-12-18 18:38:49', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','3700','1','297250','1500','298750','0');
update buybill set dailyentryid='0,' where buybillid=14151;
UPDATE product SET overAllAveragePrice = 300 WHERE productId = 16473;;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:08:50";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:38:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:38:50', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14151');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:09:29";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:39:29", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:39:29', '77', 'bill', '192.168.1.21', '', '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 ('H1679','','14','370','490', '490','490', '2024-12-18', '0', '77', '1', 'H1679', '0', '0', '0', '0', '0', '370','370','370','370','370','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','370','370','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16499, 1,'2024-12-18 18:39:51',77)
                ON DUPLICATE KEY UPDATE productid = 16499, edited = 1, sysdate = '2024-12-18 18:39: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', '16499', '1', '2024-12-18', '77', '0','1649901','490','490','490','370','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16499', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16499', '1', '0', '0', '16499', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:10:05";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:40:05", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:40:05', '77', 'add', '192.168.1.21', '', '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 ('06762fac1c5081', '2024-12-18 18:39:29', '9', '298750.00', '302450', '0', '0', '3700',  '3700', '0', '3700', '1', '2024-12-18 18:40:05', '', '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 ('H1679', '14152', '14', '16499', '10', '370', '3700', '0', '', '2024-12-18 18:40:05', '16499','','','0','0','0','0','0',null,'370','3700','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-18 18:39:29', 1, 16499, 0, 0
                    , 370, 10, 0, 0, 77, '2024-12-18 18:40:05')
                ON DUPLICATE KEY UPDATE buyprice = 370,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:40:05' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16499', '370', '10', '0', 'buyBillController.php', '32753', '', '0', '0');
UPDATE product SET  productBuyPrice = "370" WHERE productId = 16499 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32753 ;
UPDATE product SET productName = 'H1679', productDescription = '', productCatId = '14', productBuyPrice = '370.00', productSellAllPrice = '490.00', productSellUnitPrice = '490.00', productSellHalfPrice = '490.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1679',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '370',lastbuyprice_withDiscount = '370',meanbuyprice = '370',meanbuyprice_withDiscount = '370' , productbuypricereal = '370.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='370',meanbuyprice_withTax='370',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='370'  WHERE productId = '16499';
UPDATE buybilldetail SET  lastbuyprice = 370 , meanbuyprice = 370, lastbuyprice_withDiscount = 370, meanbuyprice_withDiscount = 370
        , lastbuyprice_withTax = 370, meanbuyprice_withTax = 370, lastbuyprice_withDiscountAndTax = 370
                where buybilldetailid = 32753;
UPDATE productunit SET proUnitBuyPrice  = 370 * productnumber WHERE productid = 16499;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16498';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16499', '1', '10', '0', '14152', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-18 18:39:29','0','0');
UPDATE supplier SET  suppliercurrentDebt = '302450',suppliercurrentDebtInCurrency= '302450' , userid = '77', supplierdate = '2024-12-18 18:40:05'   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', '298750.00', '3700', '0', 'اضافة فاتورة مشتريات', '14152', '302450', '2024-12-18 18:39:29', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','3700','1','298750','3700','302450','0');
update buybill set dailyentryid='0,' where buybillid=14152;
COMMIT;
UPDATE product SET overAllAveragePrice = 370 WHERE productId = 16499;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:10:06";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:40:06", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:40:06', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14152');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:12:16";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:42:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:42:16', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:12:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:42:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:42:28', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762fb690f5d2
-- ----------------------------------------------------------------------------------------------------

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-18 18:42:17', '06762fb690f5d2', '1', '0.00', '0', '0', '1', '310', '310', '-310', '0', '1', '2024-12-18 18:42:28', '', '104', '0', 'نقدي','1', '0', '5', '3', 'نقدي', '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','اضافة فاتورة مردوات مبيعات','16821', '0', '2024-12-18 18:42:28', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '310', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 18:42: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 ('250.00', 'R3184', '16821', '1', '15346', '1', '310', '310', '0', '', '1', '0', '15346', '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 = 583.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 583.00
        
                where returnsellbilldetailid = 22004;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15346, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 310, 250, 250, 583
                    , 250, 583, 250, 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+310, returnSellCostBuyPrice = returnSellCostBuyPrice+250, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+250
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+583, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+250
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+583
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+250
                            , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 310, 250, 250, 583
                    , 250, 583, 250, 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+310, returnSellCostBuyPrice = returnSellCostBuyPrice+250, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+250
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+583, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+250
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+583
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+250
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '104', storedetaildate = '2024-12-18 18:42:28' WHERE storedetailid = '15345';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15346', '1', '1', '0', '16821', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '6', '7', '104', '2024-12-18 18:42:28','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '9320',  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 ('9630','-310', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16821', '9320', '2024-12-18 18:42:28', '104',  'returnsellbillController.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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 310, 250, 250, 583
                    , 250, 583, 250 ,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+310, returnSellCostBuyPrice = returnSellCostBuyPrice+250, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+250
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+583, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+250
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+583
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+250
                            , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 310, 250, 250, 583
                    , 250, 583, 250 ,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+310, returnSellCostBuyPrice = returnSellCostBuyPrice+250, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+250
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+583, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+250
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+583
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+250
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -310, -250, -250
                    , -583, -250, -583, -250, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-310, netSellCostBuyPrice = netSellCostBuyPrice+-250
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-250
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-583
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-250
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-583
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-250
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762fb690f5d2 and sellbillId = 16821 and returnsellbillId = 16821
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:12:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:42:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:42:28', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:13:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:43:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:43:42', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:14:02";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:44:02", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:44:02', '77', 'bill', '192.168.1.21', '', '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 ('R3349','','1','320','380', '380','380', '2024-12-18', '0', '77', '1', 'R3349', '0', '0', '0', '0', '0', '320','320','320','320','320','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','320','320','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16500, 1,'2024-12-18 18:46:05',77)
                ON DUPLICATE KEY UPDATE productid = 16500, edited = 1, sysdate = '2024-12-18 18:46:05', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16500', '1', '2024-12-18', '77', '0','1650001','380','380','380','320','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16500', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16500', '1', '0', '0', '16500', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:16:37";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:46:37", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:46:37', '77', 'add', '192.168.1.21', '', '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 ('06762fbd28896f', '2024-12-18 18:44:02', '7', '237540.00', '245540', '0', '0', '8000',  '8000', '0', '8000', '1', '2024-12-18 18:46:37', '', '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 ('R3349', '14153', '1', '16500', '25', '320', '8000', '0', '', '2024-12-18 18:46:37', '16500','','','0','0','0','0','0',null,'320','8000','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-18 18:44:02', 1, 16500, 0, 0
                    , 320, 25, 0, 0, 77, '2024-12-18 18:46:37')
                ON DUPLICATE KEY UPDATE buyprice = 320,
                        buyQuantity =buyQuantity+25, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:46:37' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16500', '320', '25', '0', 'buyBillController.php', '32754', '', '0', '0');
UPDATE product SET  productBuyPrice = "320" WHERE productId = 16500 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32754 ;
UPDATE product SET productName = 'R3349', productDescription = '', productCatId = '1', productBuyPrice = '320.00', productSellAllPrice = '380.00', productSellUnitPrice = '380.00', productSellHalfPrice = '380.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3349',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '320',lastbuyprice_withDiscount = '320',meanbuyprice = '320',meanbuyprice_withDiscount = '320' , productbuypricereal = '320.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='320',meanbuyprice_withTax='320',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='320'  WHERE productId = '16500';
UPDATE buybilldetail SET  lastbuyprice = 320 , meanbuyprice = 320, lastbuyprice_withDiscount = 320, meanbuyprice_withDiscount = 320
        , lastbuyprice_withTax = 320, meanbuyprice_withTax = 320, lastbuyprice_withDiscountAndTax = 320
                where buybilldetailid = 32754;
UPDATE productunit SET proUnitBuyPrice  = 320 * productnumber WHERE productid = 16500;
UPDATE storedetail SET  productquantity = '25', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16499';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16500', '1', '25', '0', '14153', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '25', '77', '2024-12-18 18:44:02','0','0');
UPDATE supplier SET  suppliercurrentDebt = '245540',suppliercurrentDebtInCurrency= '245540' , userid = '77', supplierdate = '2024-12-18 18:46:37'   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', '237540.00', '8000', '0', 'اضافة فاتورة مشتريات', '14153', '245540', '2024-12-18 18:44:02', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','8000','1','237540','8000','245540','0');
update buybill set dailyentryid='0,' where buybillid=14153;
COMMIT;
UPDATE product SET overAllAveragePrice = 320 WHERE productId = 16500;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:16:38";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:46:38", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:46:38', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14153');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:16:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:46:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:46:55', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762fbbf20bea
-- ----------------------------------------------------------------------------------------------------

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-18 18:43:43', '06762fbbf20bea', '1', '0.00', '0', '0', '1', '1650.00', '1650', '1650', '0', '1', '2024-12-18 18:46:56', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '5' ,'0','','','','','-1','0','0','0','0','0','1650','0','','0','0','1650','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150123', '0', '2024-12-18 18:46:56', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1650', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 18:43:43','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+5 where id = 36156;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3318', '150123', '1', '16186', '5', '330', '1650', '0', '', '1', '2024-12-18 18:46:56', '16186', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36156-5,','1','1','0','0','330','1650','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 = 548480;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16186, '2024-12-18', 1650, 1550, 1550
                    , 1550, 1550, 1550, 1550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 5, 0, 1550, 1550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1650, sellCostBuyPrice =sellCostBuyPrice+1550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1650, 1550, 1550
                    , 1550, 1550, 1550, 1550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1550, 1550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1650, sellCostBuyPrice =sellCostBuyPrice+1550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 18:46:56' WHERE storedetailid = '16185';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16186', '1', '5', '1', '150123', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '13', '104', '2024-12-18 18:46:56','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '10970',  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 ('9320','1650', '0', '1', 'اضافة فاتورة مبيعات', '150123', '10970', '2024-12-18 18:46:56', '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-18', 1650, 1550, 1550
                    , 1550, 1550, 1550, 1550
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1550, 1550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1650, sellCostBuyPrice =sellCostBuyPrice+1550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1650, 1550, 1550
                    , 1550, 1550, 1550, 1550
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1550, 1550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1650, sellCostBuyPrice =sellCostBuyPrice+1550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1650, 1550, 1550
                    , 1550, 1550, 1550, 1550, 1550, 1550)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1650, netSellCostBuyPrice = netSellCostBuyPrice+1550
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1550
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1550
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1550
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1550
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1550
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1550
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1550;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762fbbf20bea and sellbillId = 150123 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:16:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:46:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:46:56', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:17:27";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:47:27", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:47:27', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:17:59";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:47:59", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:47:59', '77', 'add', '192.168.1.21', '', '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 ('06762fc9f423e0', '2024-12-18 18:47:27', '27', '385425.00', '389425', '0', '0', '4000',  '4000', '0', '4000', '1', '2024-12-18 18:47:59', '', '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 ('R3341', '14154', '1', '16440', '10', '400', '4000', '0', '', '2024-12-18 18:47:59', '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-18 18:47:27', 1, 16440, 0, 0
                    , 400, 10, 0, 0, 77, '2024-12-18 18:47:59')
                ON DUPLICATE KEY UPDATE buyprice = 400,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:47:59' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16440', '400', '10', '0', 'buyBillController.php', '32755', '', '0', '0');
UPDATE product SET  productBuyPrice = "400" WHERE productId = 16440 ;
UPDATE buybilldetail SET  quantitybefore = 40 WHERE buybilldetailid = 32755 ;
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 = 32755;
UPDATE productunit SET proUnitBuyPrice  = 400 * productnumber WHERE productid = 16440;
UPDATE storedetail SET  productquantity = '50', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16439';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16440', '1', '10', '0', '14154', 'اضافة فاتورة مشتريات', 'buyBillController.php', '40', '50', '77', '2024-12-18 18:47:27','0','0');
UPDATE supplier SET  suppliercurrentDebt = '389425',suppliercurrentDebtInCurrency= '389425' , userid = '77', supplierdate = '2024-12-18 18:47:59'   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', '385425.00', '4000', '0', 'اضافة فاتورة مشتريات', '14154', '389425', '2024-12-18 18:47:27', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','4000','1','385425','4000','389425','0');
update buybill set dailyentryid='0,' where buybillid=14154;
COMMIT;
UPDATE product SET overAllAveragePrice = 400 WHERE productId = 16440;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:18:00";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:48:00", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:48:00', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14154');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:18:07";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:48:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:48:07', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247475
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6579,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 18:48:08', userid = '2' WHERE clientid = '6579';
UPDATE client SET  inUse = 0 where clientid = 6579;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6579','263.00','263','1','ايصال تحصيل (( قبض من عميل ))','247475', '0', '2024-12-18 18:33:24', '2', 'clientPayedDeptController.php', '   ', '263', '0', null, '0', null, null,'', '-1','1','1','263','1','','3544','0');
UPDATE save SET  savecurrentvalue = '256600.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('256337.50','263', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247478', '256600.5', '2024-12-18 18:48:08', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '263', '263', '2024-12-18', '2', '0', '0', '2024-12-18 18:48:08','اضافة ايصال سداد للعميل راندا سعد I655','1','0','0','0','247478','clientPayedDeptController.php?do=show&id=247478');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122194', '-1', '263', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '263', 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 ('122194', '-1', '263', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-263', 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 = '6579', clientdebtchangebefore = '263.000', clientdebtchangeamount = '263.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247475', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 18:33:24', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '263.00',discount='', reciptid='0', dailyentryid = '122194',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='263',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247478';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247475 -clientdebtchangeId = 247478
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:18:09";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:48:09", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:48: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-18 15:18:36";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:48:36", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:48:36', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247479
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3671,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18 18:48:37', userid = '2' WHERE clientid = '3671';
UPDATE client SET  inUse = 0 where clientid = 3671;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3671','707.00','707','1','ايصال تحصيل (( قبض من عميل ))','247479', '0', '2024-12-18 18:48:09', '2', 'clientPayedDeptController.php', '   ', '707', '0', null, '0', null, null,'', '-1','1','1','707','1','','3545','0');
UPDATE save SET  savecurrentvalue = '257307.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('256600.50','707', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247479', '257307.5', '2024-12-18 18:48:37', '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 ('ايمان الحفناوي 41', 'ايمان الحفناوي 41', 'ايمان الحفناوي 41', 'ايمان الحفناوي 41', '58', '0', '0.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-18 18:48:37');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '707', '707', '2024-12-18', '2', '0', '0', '2024-12-18 18:48:37','اضافة ايصال سداد للعميل ايمان الحفناوي 41','1','0','0','0','247479','clientPayedDeptController.php?do=show&id=247479');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122195', '-1', '707', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '707', 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 ('122195', '12565', '707', '','0');
UPDATE accountstree SET name = 'ايمان الحفناوي 41', customName = 'ايمان الحفناوي 41', customNameEn = 'ايمان الحفناوي 41', nameEn = 'ايمان الحفناوي 41', parent = '58', accountNature = '0', theValue = '-707', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 18:48:37' WHERE id = '12565';
UPDATE clientdebtchange SET clientid = '3671', clientdebtchangebefore = '707.000', clientdebtchangeamount = '707.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247479', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-18 18:48:09', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '707.00',discount='', reciptid='0', dailyentryid = '122195',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='707',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247479';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:18:37";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:48:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:48: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-18 15:18:59";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:48:59", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:48:59', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247480
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6262,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '435' , clientdate = '2024-12-18 18:48:59', userid = '2' WHERE clientid = '6262';
UPDATE client SET  inUse = 0 where clientid = 6262;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6262','2106.00','1671','1','ايصال تحصيل (( قبض من عميل ))','247480', '435', '2024-12-18 18:48:38', '2', 'clientPayedDeptController.php', '   ', '1671', '0', null, '0', null, null,'', '-1','1','1','1671','1','','3546','0');
UPDATE save SET  savecurrentvalue = '258978.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('257307.50','1671', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247480', '258978.5', '2024-12-18 18:48:59', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1671', '1671', '2024-12-18', '2', '0', '0', '2024-12-18 18:48:59','اضافة ايصال سداد للعميل ام ماسة 41','1','0','0','0','247480','clientPayedDeptController.php?do=show&id=247480');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122196', '-1', '1671', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1671', 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 ('122196', '-1', '1671', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1671', 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 = '6262', clientdebtchangebefore = '2106.000', clientdebtchangeamount = '1671.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247480', clientdebtchangeafter = '435.000', clientdebtchangedate = '2024-12-18 18:48:38', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1671.00',discount='', reciptid='0', dailyentryid = '122196',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1671',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247480';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:19:00";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:49:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:49: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-18 15:19:19";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:49:19", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:49:19', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247481
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2913,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '218' , clientdate = '2024-12-18 18:49:19', userid = '2' WHERE clientid = '2913';
UPDATE client SET  inUse = 0 where clientid = 2913;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2913','1818.00','1600','1','ايصال تحصيل (( قبض من عميل ))','247481', '218', '2024-12-18 18:49:00', '2', 'clientPayedDeptController.php', '   ', '1600', '0', null, '0', null, null,'', '-1','1','1','1600','1','','3547','0');
UPDATE save SET  savecurrentvalue = '260578.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('258978.50','1600', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247481', '260578.5', '2024-12-18 18:49:19', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1600', '1600', '2024-12-18', '2', '0', '0', '2024-12-18 18:49:20','اضافة ايصال سداد للعميل اماني محمد بلطيم P8','1','0','0','0','247481','clientPayedDeptController.php?do=show&id=247481');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122197', '-1', '1600', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1600', 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 ('122197', '-1', '1600', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1600', 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 = '2913', clientdebtchangebefore = '1818.000', clientdebtchangeamount = '1600.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247481', clientdebtchangeafter = '218.000', clientdebtchangedate = '2024-12-18 18:49:00', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1600.00',discount='', reciptid='0', dailyentryid = '122197',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1600',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247481';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:19:20";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:49:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:49: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-18 15:19:37";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:49:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:49:37', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247482
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1412,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-2' , clientdate = '2024-12-18 18:49:37', userid = '2' WHERE clientid = '1412';
UPDATE client SET  inUse = 0 where clientid = 1412;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1412','604.00','606','1','ايصال تحصيل (( قبض من عميل ))','247482', '-2', '2024-12-18 18:49:20', '2', 'clientPayedDeptController.php', '   ', '606', '0', null, '0', null, null,'', '-1','1','1','606','1','','3548','0');
UPDATE save SET  savecurrentvalue = '261184.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('260578.50','606', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247482', '261184.5', '2024-12-18 18:49:37', '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', '-2.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-18 18:49:37');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '606', '606', '2024-12-18', '2', '0', '0', '2024-12-18 18:49:37','اضافة ايصال سداد للعميل مدام ريهام 73','1','0','0','0','247482','clientPayedDeptController.php?do=show&id=247482');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122198', '-1', '606', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '606', 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 ('122198', '12566', '606', '','0');
UPDATE accountstree SET name = 'مدام ريهام 73', customName = 'مدام ريهام 73', customNameEn = 'مدام ريهام 73', nameEn = 'مدام ريهام 73', parent = '58', accountNature = '0', theValue = '-608', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-18 18:49:37' WHERE id = '12566';
UPDATE clientdebtchange SET clientid = '1412', clientdebtchangebefore = '604.000', clientdebtchangeamount = '606.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247482', clientdebtchangeafter = '-2.000', clientdebtchangedate = '2024-12-18 18:49:20', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '606.00',discount='', reciptid='0', dailyentryid = '122198',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='606',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247482';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:19:38";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:49:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:49: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-18 15:20:21";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:50:21", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:50:21', '77', 'bill', '192.168.1.21', '', '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 ('7333','','5','240','300', '300','300', '2024-12-18', '0', '77', '1', '07333', '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 (16501, 1,'2024-12-18 18:51:23',77)
                ON DUPLICATE KEY UPDATE productid = 16501, edited = 1, sysdate = '2024-12-18 18:51: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', '16501', '1', '2024-12-18', '77', '0','1650101','300','300','300','240','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16501', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16501', '1', '0', '0', '16501', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','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 ('7334','','5','160','220', '220','220', '2024-12-18', '0', '77', '1', '07334', '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 (16502, 1,'2024-12-18 18:51:36',77)
                ON DUPLICATE KEY UPDATE productid = 16502, edited = 1, sysdate = '2024-12-18 18:51:36', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16502', '1', '2024-12-18', '77', '0','1650201','220','220','220','160','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16502', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16502', '1', '0', '0', '16502', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:21:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:51:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:51:50', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06762fc80dc08b
-- ----------------------------------------------------------------------------------------------------

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-18 18:46:56', '06762fc80dc08b', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2024-12-18 18:51:50', '', '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-18','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','اضافة فاتورة مبيعات','150124', '0', '2024-12-18 18:51:50', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 18:46:56','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:21:50";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:51:50", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:51:50', '2', 'add', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');
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', '150124', '5', '16415', '1', '200', '200', '0', '', '1', '2024-12-18 18:51:50', '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 = 548481;
 INSERT INTO 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-18', 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-18', 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 = '22', userid = '104', storedetaildate = '2024-12-18 18:51:50' WHERE storedetailid = '16414';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16415', '1', '1', '1', '150124', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '104', '2024-12-18 18:51:50','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '11170',  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 ('10970','200', '0', '1', 'اضافة فاتورة مبيعات', '150124', '11170', '2024-12-18 18:51:50', '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-18', 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-18', 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;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247483
-- ----------------------------------------------------------------------------------------------------

BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762fc80dc08b and sellbillId = 150124 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

CALL clientInUse(6262,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-365' , clientdate = '2024-12-18 18:51:50', userid = '2' WHERE clientid = '6262';
UPDATE client SET  inUse = 0 where clientid = 6262;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6262','435.00','800','1','ايصال تحصيل (( قبض من عميل ))','247483', '-365', '2024-12-18 18:49:38', '2', 'clientPayedDeptController.php', '   ', '800', '0', null, '0', null, null,'', '-1','1','1','800','1','','3549','0');
UPDATE save SET  savecurrentvalue = '261984.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('261184.50','800', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '247484', '261984.5', '2024-12-18 18:51:50', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '800', '800', '2024-12-18', '2', '0', '0', '2024-12-18 18:51:50','اضافة ايصال سداد للعميل ام ماسة 41','1','0','0','0','247484','clientPayedDeptController.php?do=show&id=247484');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122199', '-1', '800', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '800', 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 ('122199', '-1', '800', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-800', 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 = '6262', clientdebtchangebefore = '435.000', clientdebtchangeamount = '800.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247483', clientdebtchangeafter = '-365.000', clientdebtchangedate = '2024-12-18 18:49:38', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '800.00',discount='', reciptid='0', dailyentryid = '122199',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='800',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247484';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247483 -clientdebtchangeId = 247484
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:21:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:51:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:51:51', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:21:51";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 18:51:51", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:51:51', '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 ('7335','','5','130','180', '180','180', '2024-12-18', '0', '77', '1', '07335', '0', '0', '0', '0', '0', '130','130','130','130','130','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','130','130','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16503, 1,'2024-12-18 18:51:54',77)
                ON DUPLICATE KEY UPDATE productid = 16503, edited = 1, sysdate = '2024-12-18 18:51: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', '16503', '1', '2024-12-18', '77', '0','1650301','180','180','180','130','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16503', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16503', '1', '0', '0', '16503', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:22:11";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:52:11", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:52:11', '77', 'add', '192.168.1.21', '', '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 ('06762fd4d71bda', '2024-12-18 18:50:21', '102', '188060.00', '204360', '0', '0', '16300',  '16300', '0', '16300', '1', '2024-12-18 18:52:11', '', '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 ('06861', '14155', '5', '15635', '15', '240', '3600', '0', '', '2024-12-18 18:52:11', '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-18 18:50:21', 1, 15635, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-18 18:52:11')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:52:11' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15635', '240', '15', '0', 'buyBillController.php', '32756', '', '0', '0');
UPDATE product SET  productBuyPrice = "240" WHERE productId = 15635 ;
UPDATE buybilldetail SET  quantitybefore = 1 WHERE buybilldetailid = 32756 ;
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.36',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='241',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 = 241, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32756;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 15635;
UPDATE storedetail SET  productquantity = '16', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '15634';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15635', '1', '15', '0', '14155', 'اضافة فاتورة مشتريات', 'buyBillController.php', '1', '16', '77', '2024-12-18 18:50:21','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 ('07252', '14155', '5', '16337', '15', '230', '3450', '0', '', '2024-12-18 18:52:11', '16337','','','0','0','0','0','0',null,'230','3450','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-18 18:50:21', 1, 16337, 0, 0
                    , 230, 15, 0, 0, 77, '2024-12-18 18:52:11')
                ON DUPLICATE KEY UPDATE buyprice = 230,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:52:11' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16337', '230', '15', '0', 'buyBillController.php', '32757', '', '0', '0');
UPDATE product SET  productBuyPrice = "230" WHERE productId = 16337 ;
UPDATE buybilldetail SET  quantitybefore = 22 WHERE buybilldetailid = 32757 ;
UPDATE product SET productName = '7252', productDescription = '', productCatId = '5', productBuyPrice = '230.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300.00', productDate = '2024-12-07', conditions = '0', userId = '77', limitamount = '1', parcode = '07252',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '230',lastbuyprice_withDiscount = '230',meanbuyprice = '230',meanbuyprice_withDiscount = '230' , productbuypricereal = '230.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='230',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='230',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 = '16337';
UPDATE buybilldetail SET  lastbuyprice = 230 , meanbuyprice = 230, lastbuyprice_withDiscount = 230, meanbuyprice_withDiscount = 230
        , lastbuyprice_withTax = 230, meanbuyprice_withTax = 230, lastbuyprice_withDiscountAndTax = 230
                where buybilldetailid = 32757;
UPDATE productunit SET proUnitBuyPrice  = 230 * productnumber WHERE productid = 16337;
UPDATE storedetail SET  productquantity = '37', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16336';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16337', '1', '15', '0', '14155', 'اضافة فاتورة مشتريات', 'buyBillController.php', '22', '37', '77', '2024-12-18 18:50:21','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 ('07333', '14155', '5', '16501', '15', '240', '3600', '0', '', '2024-12-18 18:52:11', '16501','','','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-18 18:50:21', 1, 16501, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-18 18:52:11')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:52:11' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16501', '240', '15', '0', 'buyBillController.php', '32758', '', '0', '0');
UPDATE product SET  productBuyPrice = "240" WHERE productId = 16501 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32758 ;
UPDATE product SET productName = '7333', 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 = '07333',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 = '16501';
UPDATE buybilldetail SET  lastbuyprice = 240 , meanbuyprice = 240, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 240
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32758;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 16501;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16500';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16501', '1', '15', '0', '14155', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 18:50:21','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 ('07334', '14155', '5', '16502', '15', '160', '2400', '0', '', '2024-12-18 18:52:11', '16502','','','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-18 18:50:21', 1, 16502, 0, 0
                    , 160, 15, 0, 0, 77, '2024-12-18 18:52:11')
                ON DUPLICATE KEY UPDATE buyprice = 160,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:52:11' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16502', '160', '15', '0', 'buyBillController.php', '32759', '', '0', '0');
UPDATE product SET  productBuyPrice = "160" WHERE productId = 16502 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32759 ;
UPDATE product SET productName = '7334', productDescription = '', productCatId = '5', productBuyPrice = '160.00', productSellAllPrice = '220.00', productSellUnitPrice = '220.00', productSellHalfPrice = '220.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07334',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 = '16502';
UPDATE buybilldetail SET  lastbuyprice = 160 , meanbuyprice = 160, lastbuyprice_withDiscount = 160, meanbuyprice_withDiscount = 160
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 160, lastbuyprice_withDiscountAndTax = 160
                where buybilldetailid = 32759;
UPDATE productunit SET proUnitBuyPrice  = 160 * productnumber WHERE productid = 16502;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16501';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16502', '1', '15', '0', '14155', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 18:50:21','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 ('07335', '14155', '5', '16503', '25', '130', '3250', '0', '', '2024-12-18 18:52:11', '16503','','','0','0','0','0','0',null,'130','3250','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-18 18:50:21', 1, 16503, 0, 0
                    , 130, 25, 0, 0, 77, '2024-12-18 18:52:11')
                ON DUPLICATE KEY UPDATE buyprice = 130,
                        buyQuantity =buyQuantity+25, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:52:11' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16503', '130', '25', '0', 'buyBillController.php', '32760', '', '0', '0');
UPDATE product SET  productBuyPrice = "130" WHERE productId = 16503 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32760 ;
UPDATE product SET productName = '7335', productDescription = '', productCatId = '5', productBuyPrice = '130.00', productSellAllPrice = '180.00', productSellUnitPrice = '180.00', productSellHalfPrice = '180.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07335',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '130',lastbuyprice_withDiscount = '130',meanbuyprice = '130',meanbuyprice_withDiscount = '130' , productbuypricereal = '130.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='130',meanbuyprice_withTax='130',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='130'  WHERE productId = '16503';
UPDATE buybilldetail SET  lastbuyprice = 130 , meanbuyprice = 130, lastbuyprice_withDiscount = 130, meanbuyprice_withDiscount = 130
        , lastbuyprice_withTax = 130, meanbuyprice_withTax = 130, lastbuyprice_withDiscountAndTax = 130
                where buybilldetailid = 32760;
UPDATE productunit SET proUnitBuyPrice  = 130 * productnumber WHERE productid = 16503;
UPDATE storedetail SET  productquantity = '25', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16502';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16503', '1', '25', '0', '14155', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '25', '77', '2024-12-18 18:50:21','0','0');
UPDATE supplier SET  suppliercurrentDebt = '204360',suppliercurrentDebtInCurrency= '204360' , userid = '77', supplierdate = '2024-12-18 18:52:11'   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', '188060.00', '16300', '0', 'اضافة فاتورة مشتريات', '14155', '204360', '2024-12-18 18:50:21', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','16300','1','188060','16300','204360','0');
update buybill set dailyentryid='0,' where buybillid=14155;
COMMIT;
UPDATE product SET overAllAveragePrice = 236.67 WHERE productId = 15635;UPDATE product SET overAllAveragePrice = 230 WHERE productId = 16337;UPDATE product SET overAllAveragePrice = 240 WHERE productId = 16501;UPDATE product SET overAllAveragePrice = 160 WHERE productId = 16502;UPDATE product SET overAllAveragePrice = 130 WHERE productId = 16503;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:22:12";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:52:12", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:52:12', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14155');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:22:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:52:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 18:52:57', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:23:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:53:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 18:53:13', '104', 'add', '192.168.1.13', '', '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-18', '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 = '11120',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('11170.00','50', '1', '1', 'إضافة مصروف', '25831', '11120', '2024-12-18 18:53:13', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'محمد اشرف', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-18', 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 = '25831';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:23:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:53:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 18:53:14', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:23:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:53:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 18:53:15', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:23:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:53:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 18:53:17', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:23:42";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:53:42", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:53:42', '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-18 15:23:55";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:53:55", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:53:55', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:24:03";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:54:03", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:54:03', '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-18 15:24:12";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:54:12", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:54:12', '101', 'delete', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=delete&sellbillid=149743&action=0');

-- ----------------------------------------------------------------------------------------------------
-- bill delete start - sellbill with id = 149743
-- ----------------------------------------------------------------------------------------------------

BEGIN;
UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 149743;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 18:54:12', userid = '75',delbyuserid = '101', conditions = '1'  ,billReservation= 0,billReservationDate='0000-00-00'  WHERE sellbillid = '149743';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 32019;
UPDATE sellbilldetail SET  lastbuyprice = 270.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 270.00, meanbuyprice_withDiscount = 270.00
        
                where sellbilldetailid = 546958;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14396, '2024-12-18', 255, 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-255, 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-18', 255, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-255, 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-18 18:54:12' WHERE storedetailid = '14395';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14396', '1', '1', '0', '149743', 'حذف فاتورة مبيعات', 'sellbillController.php', '3', '4', '101', '2024-12-18 18:54:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 32245;
UPDATE sellbilldetail SET  lastbuyprice = 285.00 , meanbuyprice = 399.00, lastbuyprice_withDiscount = 285.00, meanbuyprice_withDiscount = 399.00
        
                where sellbilldetailid = 546959;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14397, '2024-12-18', 255, 285, 285
                    , 399, 285, 399, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-255, sellCostBuyPrice =sellCostBuyPrice-285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-285, sellCostMeanBuyPrice = sellCostMeanBuyPrice-399
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-399
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-285
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 255, 285, 285
                    , 399, 285, 399, 285
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-255, sellCostBuyPrice =sellCostBuyPrice-285
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-285, sellCostMeanBuyPrice = sellCostMeanBuyPrice-399
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-285, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-399
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-285
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 18:54:12' WHERE storedetailid = '14396';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14397', '1', '1', '0', '149743', 'حذف فاتورة مبيعات', 'sellbillController.php', '2', '3', '101', '2024-12-18 18:54:12','0','0');
CALL clientInUse(10722,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '101' WHERE clientid = '10722';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10722','535.00','535.00','1','حذف فاتورة مبيعات','149743', '0', '2024-12-18 18:54:12', '101', 'sellbillController.php', 'حذف فاتورة مبيعات', '535', '0', null, '0', null, null,'', '0','1','1','535','1','2024-12-16 18:06:37','0','0');
UPDATE client SET  inUse = 0 where clientid = 10722;
 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-18', 535, 555, 555
                    , 669, 555, 669, 555
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-535, sellCostBuyPrice =sellCostBuyPrice-555
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-555, sellCostMeanBuyPrice = sellCostMeanBuyPrice-669
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-555, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-669
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-555
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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 (10722, '2024-12-18', 535, 555, 555
                    , 669, 555, 669, 555
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-535, sellCostBuyPrice =sellCostBuyPrice-555
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-555, sellCostMeanBuyPrice = sellCostMeanBuyPrice-669
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-555, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-669
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-555
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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, 535, 555, 555
                    , 669, 555, 669, 555, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-535, netSellCostBuyPrice = netSellCostBuyPrice-555
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-555
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-669
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-555
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-669
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-555
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill delete end - sellbill with id = 149743
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:24:13";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:54:13", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:54:13', '101', 'sucess', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:24:18";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:54:18", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:54:18', '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-18 15:24:40";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:54:40", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:54:40', '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-18 15:24:52";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:54:52", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:54:52', '101', 'delete', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=delete&sellbillid=145832&action=0');

-- ----------------------------------------------------------------------------------------------------
-- bill delete start - sellbill with id = 145832
-- ----------------------------------------------------------------------------------------------------

BEGIN;
UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 145832;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 18:54:52', userid = '75',delbyuserid = '101', conditions = '1'  ,billReservation= 0,billReservationDate='0000-00-00'  WHERE sellbillid = '145832';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 29914;
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 3375.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 3375.00
        
                where sellbilldetailid = 532882;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13393, '2024-12-18', 145, 250, 250
                    , 3375, 250, 3375, 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-3375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-3375
                            , 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-18', 145, 250, 250
                    , 3375, 250, 3375, 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-3375
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-3375
                            , 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-18 18:54:52' WHERE storedetailid = '13392';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13393', '1', '1', '0', '145832', 'حذف فاتورة مبيعات', 'sellbillController.php', '0', '1', '101', '2024-12-18 18:54:52','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
        
                where sellbilldetailid = 532883;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14496, '2024-12-18', 285, 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-285, 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-18', 285, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-285, 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 = '101', storedetaildate = '2024-12-18 18:54:52' WHERE storedetailid = '14495';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14496', '1', '1', '0', '145832', 'حذف فاتورة مبيعات', 'sellbillController.php', '0', '1', '101', '2024-12-18 18:54:52','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 30280;
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        
                where sellbilldetailid = 532884;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13567, '2024-12-18', 150, 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-150, 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-18', 150, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-150, 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 = '2', userid = '101', storedetaildate = '2024-12-18 18:54:52' WHERE storedetailid = '13566';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13567', '1', '1', '0', '145832', 'حذف فاتورة مبيعات', 'sellbillController.php', '1', '2', '101', '2024-12-18 18:54:52','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 30614;
UPDATE sellbilldetail SET  lastbuyprice = 175.00 , meanbuyprice = 175.00, lastbuyprice_withDiscount = 175.00, meanbuyprice_withDiscount = 175.00
        
                where sellbilldetailid = 532885;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13207, '2024-12-18', 150, 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-150, 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-18', 150, 175, 175
                    , 175, 175, 175, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-150, 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 = '101', storedetaildate = '2024-12-18 18:54:52' WHERE storedetailid = '13206';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13207', '1', '1', '0', '145832', 'حذف فاتورة مبيعات', 'sellbillController.php', '3', '4', '101', '2024-12-18 18:54:52','0','0');
CALL clientInUse(7434,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '101' WHERE clientid = '7434';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7434','758.00','758.00','1','حذف فاتورة مبيعات','145832', '0', '2024-12-18 18:54:52', '101', 'sellbillController.php', 'حذف فاتورة مبيعات', '758', '0', null, '0', null, null,'', '0','1','1','758','1','2024-11-20 18:32:16','0','0');
UPDATE client SET  inUse = 0 where clientid = 7434;
 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-18', 758, 1005, 1005
                    , 4130, 1005, 4130, 1005
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-758, sellCostBuyPrice =sellCostBuyPrice-1005
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1005, sellCostMeanBuyPrice = sellCostMeanBuyPrice-4130
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1005, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-4130
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1005
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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 (7434, '2024-12-18', 758, 1005, 1005
                    , 4130, 1005, 4130, 1005
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-758, sellCostBuyPrice =sellCostBuyPrice-1005
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-1005, sellCostMeanBuyPrice = sellCostMeanBuyPrice-4130
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-1005, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-4130
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-1005
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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, 1005, 1005
                    , 4130, 1005, 4130, 1005, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-758, netSellCostBuyPrice = netSellCostBuyPrice-1005
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-1005
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-4130
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-1005
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-4130
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-1005
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill delete end - sellbill with id = 145832
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:24:53";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:54:53", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:54:53', '101', 'sucess', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:24:56";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:54:56", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:54:56', '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-18 15:25:15";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:55:15", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:55: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-18 15:26:00";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:56:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:56:00', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:26:13";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:56:13", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:56:13', '101', 'delete', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=delete&sellbillid=145788&action=0');

-- ----------------------------------------------------------------------------------------------------
-- bill delete start - sellbill with id = 145788
-- ----------------------------------------------------------------------------------------------------

BEGIN;
UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 145788;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 18:56:14', userid = '75',delbyuserid = '101', conditions = '1'  ,billReservation= 0,billReservationDate='0000-00-00'  WHERE sellbillid = '145788';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 33966;
UPDATE sellbilldetail SET  lastbuyprice = 550.00 , meanbuyprice = 550.00, lastbuyprice_withDiscount = 550.00, meanbuyprice_withDiscount = 550.00
        
                where sellbilldetailid = 532684;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15232, '2024-12-18', 620, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-620, sellCostBuyPrice =sellCostBuyPrice-550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-550, sellCostMeanBuyPrice = sellCostMeanBuyPrice-550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 620, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-620, sellCostBuyPrice =sellCostBuyPrice-550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-550, sellCostMeanBuyPrice = sellCostMeanBuyPrice-550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-18 18:56:14' WHERE storedetailid = '15231';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15232', '1', '1', '0', '145788', 'حذف فاتورة مبيعات', 'sellbillController.php', '6', '7', '101', '2024-12-18 18:56:14','0','0');
CALL clientInUse(3391,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '15', userid = '101' WHERE clientid = '3391';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3391','662.00','647.00','1','حذف فاتورة مبيعات','145788', '15', '2024-12-18 18:56:14', '101', 'sellbillController.php', 'حذف فاتورة مبيعات', '647', '0', null, '0', null, null,'', '0','1','1','647','1','2024-11-20 16:27:22','0','0');
UPDATE client SET  inUse = 0 where clientid = 3391;
 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-18', 647, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-647, sellCostBuyPrice =sellCostBuyPrice-550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-550, sellCostMeanBuyPrice = sellCostMeanBuyPrice-550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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 (3391, '2024-12-18', 647, 550, 550
                    , 550, 550, 550, 550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-647, sellCostBuyPrice =sellCostBuyPrice-550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-550, sellCostMeanBuyPrice = sellCostMeanBuyPrice-550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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, 647, 550, 550
                    , 550, 550, 550, 550, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-647, netSellCostBuyPrice = netSellCostBuyPrice-550
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-550
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-550
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-550
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-550
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-550
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill delete end - sellbill with id = 145788
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:26:14";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:56:14", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:56:14', '101', 'sucess', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:26:16";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:56:16", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:56:16', '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-18 15:26:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:56:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:56:20', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247487
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3677,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-8355' , clientdate = '2024-12-18 18:56:21', userid = '104' WHERE clientid = '3677';
UPDATE client SET  inUse = 0 where clientid = 3677;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3677','-6955.00','1400','1','ايصال تحصيل (( قبض من عميل ))','247487', '-8355', '2024-12-18 18:56:00', '104', 'clientPayedDeptController.php', '   ', '1400', '0', null, '0', null, null,'', '-1','1','1','1400','1','','3550','0');
UPDATE save SET  savecurrentvalue = '12520',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('11120.00','1400', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '247488', '12520', '2024-12-18 18:56:21', '104',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1400', '1400', '2024-12-18', '104', '0', '0', '2024-12-18 18:56:21','اضافة ايصال سداد للعميل زيادة ','1','0','-1','0','247488','clientPayedDeptController.php?do=show&id=247488');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122200', '-1', '1400', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1400', 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 ('122200', '-1', '1400', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1400', 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 = '3677', clientdebtchangebefore = '-6955.000', clientdebtchangeamount = '1400.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247487', clientdebtchangeafter = '-8355.000', clientdebtchangedate = '2024-12-18 18:56:00', userid = '104', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1400.00',discount='', reciptid='0', dailyentryid = '122200',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1400',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247488';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =247487 -clientdebtchangeId = 247488
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:26:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:56:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:56:22', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:26:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:56:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 18:56:23', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:26:44";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:56:44", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:56:44', '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-18 15:27:00";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:57:00", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:57:00', '101', 'delete', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=delete&sellbillid=149705&action=0');

-- ----------------------------------------------------------------------------------------------------
-- bill delete start - sellbill with id = 149705
-- ----------------------------------------------------------------------------------------------------

BEGIN;
UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 149705;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 18:57:01', userid = '75',delbyuserid = '101', conditions = '1'  ,billReservation= 0,billReservationDate='0000-00-00'  WHERE sellbillid = '149705';
UPDATE sellbilldetail SET  lastbuyprice = 285.00 , meanbuyprice = 283.00, lastbuyprice_withDiscount = 285.00, meanbuyprice_withDiscount = 283.00
        
                where sellbilldetailid = 546807;
 INSERT INTO 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-18', 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-18', 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 = '-3', userid = '101', storedetaildate = '2024-12-18 18:57:01' WHERE storedetailid = '11924';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11925', '1', '1', '0', '149705', 'حذف فاتورة مبيعات', 'sellbillController.php', '-4', '-3', '101', '2024-12-18 18:57:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 33214;
UPDATE sellbilldetail SET  lastbuyprice = 110.00 , meanbuyprice = 113.00, lastbuyprice_withDiscount = 110.00, meanbuyprice_withDiscount = 113.00
        
                where sellbilldetailid = 546808;
 INSERT INTO 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-18', 135, 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-135, 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-18', 135, 110, 110
                    , 113, 110, 113, 113.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-135, 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-18 18:57:01' WHERE storedetailid = '14755';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14756', '1', '1', '0', '149705', 'حذف فاتورة مبيعات', 'sellbillController.php', '1', '2', '101', '2024-12-18 18:57:01','0','0');
CALL clientInUse(10720,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '101' WHERE clientid = '10720';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10720','354.00','354.00','1','حذف فاتورة مبيعات','149705', '0', '2024-12-18 18:57:01', '101', 'sellbillController.php', 'حذف فاتورة مبيعات', '354', '0', null, '0', null, null,'', '0','1','1','354','1','2024-12-16 16:33:22','0','0');
UPDATE client SET  inUse = 0 where clientid = 10720;
 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-18', 354, 395, 395
                    , 396, 395, 396, 395
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-354, sellCostBuyPrice =sellCostBuyPrice-395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-395, sellCostMeanBuyPrice = sellCostMeanBuyPrice-396
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-396
                            , 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 (10720, '2024-12-18', 354, 395, 395
                    , 396, 395, 396, 395
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-354, sellCostBuyPrice =sellCostBuyPrice-395
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-395, sellCostMeanBuyPrice = sellCostMeanBuyPrice-396
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-395, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-396
                            , 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, 354, 395, 395
                    , 396, 395, 396, 395, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-354, netSellCostBuyPrice = netSellCostBuyPrice-395
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-395
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-396
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-395
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-396
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-395
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill delete end - sellbill with id = 149705
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:27:01";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:57:01", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:57:01', '101', 'sucess', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:27:04";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:57:04", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:57:04', '101', 'show', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
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='745',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16454';
UPDATE product SET productName = '7305', productDescription = '', productCatId = '5', productBuyPrice = '735', 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 = '745.00',lastbuyprice_withDiscount = '745',meanbuyprice = '740',meanbuyprice_withDiscount = '740' , productbuypricereal = '745' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='745',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='745',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 user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:27:41";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 18:57:41", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 18:57: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-18 15:27:42";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:57:42", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:57:42', '77', 'add', '192.168.1.21', '', '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 ('06762fe2362af3', '2024-12-18 18:53:55', '27', '389425.00', '411400', '0', '0', '21975',  '21975', '0', '21975', '1', '2024-12-18 18:57:42', '', '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 ('07305', '14156', '5', '16454', '15', '735', '11025', '0', '', '2024-12-18 18:57:42', '16454','','','0','0','0','0','0',null,'735','11025','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-18 18:53:55', 1, 16454, 0, 0
                    , 735, 15, 0, 0, 77, '2024-12-18 18:57:42')
                ON DUPLICATE KEY UPDATE buyprice = 735,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:57:42' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16454', '735', '15', '0', 'buyBillController.php', '32761', '', '0', '0');
UPDATE product SET  productBuyPrice = "735" WHERE productId = 16454 ;
UPDATE buybilldetail SET  quantitybefore = 10 WHERE buybilldetailid = 32761 ;
UPDATE product SET productName = '7305', productDescription = '', productCatId = '5', productBuyPrice = '735.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 = '735',lastbuyprice_withDiscount = '735',meanbuyprice = '737',meanbuyprice_withDiscount = '737' , 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='745',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 buybilldetail SET  lastbuyprice = 735 , meanbuyprice = 737, lastbuyprice_withDiscount = 735, meanbuyprice_withDiscount = 737
        , lastbuyprice_withTax = 735, meanbuyprice_withTax = 739, lastbuyprice_withDiscountAndTax = 735
                where buybilldetailid = 32761;
UPDATE productunit SET proUnitBuyPrice  = 735 * productnumber WHERE productid = 16454;
UPDATE storedetail SET  productquantity = '25', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16453';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16454', '1', '15', '0', '14156', 'اضافة فاتورة مشتريات', 'buyBillController.php', '10', '25', '77', '2024-12-18 18:53:55','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 ('07143', '14156', '5', '16205', '15', '730', '10950', '0', '', '2024-12-18 18:57:42', '16205','','','0','0','0','0','0',null,'730','10950','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-18 18:53:55', 1, 16205, 0, 0
                    , 730, 15, 0, 0, 77, '2024-12-18 18:57:42')
                ON DUPLICATE KEY UPDATE buyprice = 730,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 18:57:42' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16205', '730', '15', '0', 'buyBillController.php', '32762', '', '0', '0');
UPDATE product SET  productBuyPrice = "730" WHERE productId = 16205 ;
UPDATE buybilldetail SET  quantitybefore = 48 WHERE buybilldetailid = 32762 ;
UPDATE product SET productName = '7143', productDescription = '', productCatId = '5', productBuyPrice = '730.00', productSellAllPrice = '810.00', productSellUnitPrice = '810.00', productSellHalfPrice = '810.00', productDate = '2024-11-30', conditions = '0', userId = '77', limitamount = '1', parcode = '07143',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '730',lastbuyprice_withDiscount = '730',meanbuyprice = '730',meanbuyprice_withDiscount = '730' , productbuypricereal = '730.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='730',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='730',meanbuyprice_withTax='730',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='730'  WHERE productId = '16205';
UPDATE buybilldetail SET  lastbuyprice = 730 , meanbuyprice = 730, lastbuyprice_withDiscount = 730, meanbuyprice_withDiscount = 730
        , lastbuyprice_withTax = 730, meanbuyprice_withTax = 730, lastbuyprice_withDiscountAndTax = 730
                where buybilldetailid = 32762;
UPDATE productunit SET proUnitBuyPrice  = 730 * productnumber WHERE productid = 16205;
UPDATE storedetail SET  productquantity = '63', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '15', '0', '14156', 'اضافة فاتورة مشتريات', 'buyBillController.php', '48', '63', '77', '2024-12-18 18:53:55','0','0');
UPDATE supplier SET  suppliercurrentDebt = '411400',suppliercurrentDebtInCurrency= '411400' , userid = '77', supplierdate = '2024-12-18 18:57:42'   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', '389425.00', '21975', '0', 'اضافة فاتورة مشتريات', '14156', '411400', '2024-12-18 18:53:55', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','21975','1','389425','21975','411400','0');
update buybill set dailyentryid='0,' where buybillid=14156;
COMMIT;
UPDATE product SET overAllAveragePrice = 730 WHERE productId = 16205;UPDATE product SET overAllAveragePrice = 740 WHERE productId = 16454;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:27:43";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 18:57:43", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 18:57:43', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14156');
UPDATE user SET loginip = "" WHERE userid = 75;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:27:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 18:57:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 18:57:55', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:32:58";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:02:58", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:02:58', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:33:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:03:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:03:32', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676300427323d
-- ----------------------------------------------------------------------------------------------------

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-18 19:02:58', '0676300427323d', '1', '0.00', '0', '0', '1', '620.00', '620', '620', '0', '1', '2024-12-18 19:03:32', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','620','0','','0','0','620','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150125', '0', '2024-12-18 19:03:32', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '620', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 19:02:58','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34434;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3205', '150125', '1', '15411', '1', '620', '620', '0', '', '1', '2024-12-18 19:03:32', '15411', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34434-1,','1','1','0','0','620','620','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 = 548482;
 INSERT INTO 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-18', 620, 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+620, 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-18', 620, 550, 550
                    , 548, 550, 548, 502.35
                    , 0, 0, 0, 0
                    , 0, 0, 0, 550, 471, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, 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 = '89', userid = '104', storedetaildate = '2024-12-18 19:03:32' WHERE storedetailid = '15410';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15411', '1', '1', '1', '150125', 'اضافة فاتورة مبيعات', 'sellbillController.php', '90', '89', '104', '2024-12-18 19:03:32','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '13140',  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 ('12520','620', '0', '1', 'اضافة فاتورة مبيعات', '150125', '13140', '2024-12-18 19:03:32', '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-18', 620, 550, 550
                    , 548, 550, 548, 502.35
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 471, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, 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-18', 620, 550, 550
                    , 548, 550, 548, 502.35
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 471, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, 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, 620, 550, 550
                    , 548, 550, 548, 502.35, 550, 471)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+620, 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 0676300427323d and sellbillId = 150125 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:33:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:03:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:03:33', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:33:40";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:03:40", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 19:03:40', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:33:58";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:03:58", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:03:58', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:33:59";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:03:59", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 19:03:59', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:34:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:04:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:04:11', '104', 'add', '192.168.1.13', '', '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-18', '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 = '13090',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('13140.00','50', '1', '1', 'إضافة مصروف', '25832', '13090', '2024-12-18 19:04:12', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'عمر', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-18', 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 = '25832';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:34:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:04:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:04:12', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:34:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:04:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:04:14', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:34:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:04:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:04:14', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:34:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:04:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:04:23', '104', 'add', '192.168.1.13', '', '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-18', '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 = '12990',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('13090.00','100', '1', '1', 'إضافة مصروف', '25833', '12990', '2024-12-18 19:04:23', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'ملك سيد التؤام', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-18', 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 = '25833';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:34:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:04:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:04:23', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:34:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:04:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:04:25', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:34:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:04:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:04:39', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:35:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:05:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:05:23', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:35:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:05:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:05:50', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676300d3dfc79
-- ----------------------------------------------------------------------------------------------------

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-18 19:05:23', '0676300d3dfc79', '1', '0.00', '0', '0', '1', '550.00', '550', '550', '0', '1', '2024-12-18 19:05:50', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150126', '0', '2024-12-18 19:05:50', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '550', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 19:05:23','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36445;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1579', '150126', '14', '16197', '1', '550', '550', '0', '', '1', '2024-12-18 19:05:50', '16197', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36445-1,','1','1','0','0','550','550','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 510.00 , meanbuyprice = 509.00, lastbuyprice_withDiscount = 510.00, meanbuyprice_withDiscount = 509.00
        , lastbuyprice_withTax = 510, meanbuyprice_withTax = 508, lastbuyprice_withDiscountAndTax = 510
                where sellbilldetailid = 548483;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16197, '2024-12-18', 550, 510, 510
                    , 509, 510, 509, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 510, 508, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+509
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+509
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+510
                            , 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+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 550, 510, 510
                    , 509, 510, 509, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 510, 508, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+509
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+509
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+510
                            , 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 = '9', userid = '104', storedetaildate = '2024-12-18 19:05:50' WHERE storedetailid = '16196';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16197', '1', '1', '1', '150126', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-18 19:05:50','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '13540',  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 ('12990','550', '0', '1', 'اضافة فاتورة مبيعات', '150126', '13540', '2024-12-18 19:05: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-18', 550, 510, 510
                    , 509, 510, 509, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,510, 508, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+509
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+509
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+510
                            , 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;
 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-18', 550, 510, 510
                    , 509, 510, 509, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,510, 508, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+510
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+510, sellCostMeanBuyPrice = sellCostMeanBuyPrice+509
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+510, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+509
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+510
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 550, 510, 510
                    , 509, 510, 509, 500, 510, 508)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+550, netSellCostBuyPrice = netSellCostBuyPrice+510
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+510
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+509
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+510
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+509
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+500
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+510
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+508;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676300d3dfc79 and sellbillId = 150126 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676300a7f3dca
-- ----------------------------------------------------------------------------------------------------

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-18 19:04:40', '0676300a7f3dca', '1', '0.00', '0', '0', '1', '10.00', '10', '10', '0', '1', '2024-12-18 19:06:43', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','10','0','','0','0','10','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150127', '0', '2024-12-18 19:06:43', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '10', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 19:04: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 ('0','10291', '150127', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-18 19:06: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');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '13550',  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 ('13540','10', '0', '1', 'اضافة فاتورة مبيعات', '150127', '13550', '2024-12-18 19:06:43', '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-18', 10, 0, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+10, 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+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 10, 0, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+10, 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+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 10, 0, 0
                    , 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+10, netSellCostBuyPrice = netSellCostBuyPrice+0
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+0
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+0
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+0
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+0
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676300a7f3dca and sellbillId = 150127 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:36:43";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:06:43", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:06:43', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:36:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:06:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 19:06:57', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:37:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:07:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 19:07:06', '104', 'add', '192.168.1.13', '', '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', '630', '2024-12-18', '104', '0', '0','','1','1','0','0','630');
UPDATE save SET  savecurrentvalue = '12920',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('13550.00','630', '1', '1', 'تحويل امول الى الخزنة  [ فودافون كاش ] ', '3526', '12920', '2024-12-18 19:07:06', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '262614.5',  userid = '104' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('261984.50','630', '0', '2', 'تحويل امول من الخزنة  [ نقدي ] ', '3526', '262614.5', '2024-12-18 19:07:06', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '2', transfermoneyvalue = '630.00', transfermoneydate = '2024-12-18', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='630' WHERE transfermoneyid = '3526';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:37:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:07:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 19:07:07', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:37:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:07:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 19:07:09', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:37:31";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 19:07:31", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:07: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 06762ff05ba142
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3095,@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-18 18:57:41', '06762ff05ba142', '3095', '0.00', '6075', '0', '1', '6075.00', '6075', '0', '6075', '1', '2024-12-18 19:07:32', '', '101', '0', 'اسراء رزق K36', '2', '1', '3', '79', 'اسراء رزق K36', '20' ,'0','','','','','-1','0','0','0','0','0','6075','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '6075', userid = '101' WHERE clientid = '3095';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3095','0.00','6075','0','اضافة فاتورة مبيعات','150128', '6075', '2024-12-18 19:07:32', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '6075', '0', null, '0', null, null,'', '0','1','1','6075','1','2024-12-18 18:57:41','0','0');
UPDATE client SET  inUse = 0 where clientid = 3095;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35890;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07215', '150128', '5', '16288', '1', '210', '210', '0', '', '1', '2024-12-18 19:07:32', '16288', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35890-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 = 548485;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16288, '2024-12-18', 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-18', 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 = '8', userid = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '16287';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16288', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '101', '2024-12-18 19:07:32','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', '150128', '1', '16077', '1', '350', '350', '0', '', '1', '2024-12-18 19:07:32', '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 = 548486;
 INSERT INTO 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-18', 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-18', 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 = '6', userid = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '16076';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16077', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '101', '2024-12-18 19:07:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36149;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1594', '150128', '14', '16208', '1', '300', '300', '0', '', '1', '2024-12-18 19:07:32', '16208', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36149-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 = 548487;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16208, '2024-12-18', 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-18', 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 = '23', userid = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '16207';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16208', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '101', '2024-12-18 19:07: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 ('210','H1585', '150128', '14', '16163', '1', '280', '280', '0', '', '1', '2024-12-18 19:07:32', '16163', '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 = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where sellbilldetailid = 548488;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16163, '2024-12-18', 280, 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+280, 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-18', 280, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, 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 = '-1', userid = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '16162';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16163', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '101', '2024-12-18 19:07:32','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', '150128', '14', '16318', '1', '650', '650', '0', '', '1', '2024-12-18 19:07:32', '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 = 548489;
 INSERT INTO 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-18', 650, 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+650, 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-18', 650, 570, 570
                    , 569, 570, 569, 570
                    , 0, 0, 0, 0
                    , 0, 0, 0, 570, 568, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+650, 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 = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '16317';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16318', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '101', '2024-12-18 19:07:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36396;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07194', '150128', '5', '16358', '1', '250', '250', '0', '', '1', '2024-12-18 19:07:32', '16358', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36396-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
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 548490;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16358, '2024-12-18', 250, 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+250, 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-18', 250, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 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+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 = '10', userid = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '16357';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16358', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '101', '2024-12-18 19:07:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36305;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06935', '150128', '5', '15812', '1', '210', '210', '0', '', '1', '2024-12-18 19:07:32', '15812', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36305-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 = 548491;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15812, '2024-12-18', 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-18', 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 = '0', userid = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '15811';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15812', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '101', '2024-12-18 19:07:32','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', '150128', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-18 19:07:32', '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 = 548492;
 INSERT INTO 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-18', 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-18', 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 = '36', userid = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37', '36', '101', '2024-12-18 19:07:32','0','0');
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', '150128', '5', '15970', '1', '200', '200', '0', '', '1', '2024-12-18 19:07:32', '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 = 548493;
 INSERT INTO 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-18', 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-18', 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 = '22', userid = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '15969';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15970', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '101', '2024-12-18 19:07:32','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', '150128', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-18 19:07:32', '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 = 548494;
 INSERT INTO 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-18', 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-18', 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 = '45', userid = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '46', '45', '101', '2024-12-18 19:07:32','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', '150128', '5', '15635', '1', '300', '300', '0', '', '1', '2024-12-18 19:07:32', '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 = 548495;
 INSERT INTO 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-18', 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-18', 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 = '15', userid = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '15634';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15635', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '101', '2024-12-18 19:07:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35740;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1481', '150128', '14', '15929', '1', '410', '410', '0', '', '1', '2024-12-18 19:07:32', '15929', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35740-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 = 548496;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15929, '2024-12-18', 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-18', 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 = '0', userid = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '15928';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15929', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '101', '2024-12-18 19:07:32','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', '150128', '5', '15673', '1', '360', '360', '0', '', '1', '2024-12-18 19:07:32', '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 = 548497;
 INSERT INTO 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-18', 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-18', 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 = '36', userid = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '15672';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15673', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37', '36', '101', '2024-12-18 19:07: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 ('240','07161', '150128', '5', '16224', '1', '300', '300', '0', '', '1', '2024-12-18 19:07:32', '16224', '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 = 240.00 , meanbuyprice = 243.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 243.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 246, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 548498;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16224, '2024-12-18', 300, 240, 240
                    , 243, 240, 243, 246.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 246, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+243
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+243
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+246.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+246
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 300, 240, 240
                    , 243, 240, 243, 246.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 246, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+243
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+243
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+246.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+246
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 19:07:32' WHERE storedetailid = '16223';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16224', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '101', '2024-12-18 19:07:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36160;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07273', '150128', '5', '16395', '1', '600', '600', '0', '', '1', '2024-12-18 19:07:32', '16395', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36160-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 499.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 499.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 500, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 548499;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16395, '2024-12-18', 600, 500, 500
                    , 499, 500, 499, 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+499
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+499
                            , 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-18', 600, 500, 500
                    , 499, 500, 499, 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+499
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+499
                            , 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 = '40', userid = '101', storedetaildate = '2024-12-18 19:07:32' WHERE storedetailid = '16394';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16395', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '41', '40', '101', '2024-12-18 19:07:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35864;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07168', '150128', '5', '16270', '1', '570', '570', '0', '', '1', '2024-12-18 19:07:33', '16270', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35864-1,','1','1','0','0','570','570','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 = 548500;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16270, '2024-12-18', 570, 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+570, 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-18', 570, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 500, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+570, 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 = '4', userid = '101', storedetaildate = '2024-12-18 19:07:33' WHERE storedetailid = '16269';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16270', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '101', '2024-12-18 19:07:33','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', '150128', '5', '16337', '1', '280', '280', '0', '', '1', '2024-12-18 19:07:33', '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 = 548501;
 INSERT INTO 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-18', 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-18', 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 = '36', userid = '101', storedetaildate = '2024-12-18 19:07:33' WHERE storedetailid = '16336';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16337', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37', '36', '101', '2024-12-18 19:07:33','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', '150128', '5', '16091', '1', '285', '285', '0', '', '1', '2024-12-18 19:07:33', '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 = 548502;
 INSERT INTO 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-18', 285, 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+285, 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-18', 285, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 235, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+285, 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 = '22', userid = '101', storedetaildate = '2024-12-18 19:07:33' WHERE storedetailid = '16090';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16091', '1', '1', '1', '150128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '101', '2024-12-18 19:07: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', '150128', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 19:07: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', '150128', '17', '10291', '1', '60', '60', '0', '', '1', '2024-12-18 19:07:33', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','60','60','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 79 where clientid = 3095;
 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-18', 6075, 4900, 4900
                    , 4901, 4900, 4901, 4903.79
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,4900, 4905, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+6075, sellCostBuyPrice =sellCostBuyPrice+4900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4901
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4901
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+4903.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+4900
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+4905
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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 (3095, '2024-12-18', 6075, 4900, 4900
                    , 4901, 4900, 4901, 4903.79
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,4900, 4905, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+6075, sellCostBuyPrice =sellCostBuyPrice+4900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4901
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4901
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+4903.79
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+4900
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+4905
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 6075, 4900, 4900
                    , 4901, 4900, 4901, 4903.79, 4900, 4905)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+6075, netSellCostBuyPrice = netSellCostBuyPrice+4900
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+4900
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+4901
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+4900
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+4901
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+4903.79
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+4900
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+4905;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06762ff05ba142 and sellbillId = 150128 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:37:33";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 19:07:33", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:07:33', '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-18 15:37:47";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:07:47", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 19:07:47', '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-18 15:37:48";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:37:51";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:07:51", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:07:51', '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-18 15:37:57";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:07:57", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:07: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-18 15:38:06";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:08:06", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:08:06', '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-18 15:39:03";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:09:03", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:09:03', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150128');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:41:08";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:11:08", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:11:08', '77', 'showDetail', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150095');
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-18 15:42:10";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:12:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 19:12: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-18 15:42:10";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:42:14";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:12:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-18 19:12:14', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:42:14";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:12:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-18 19:12:14', '2', 'showallajax', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:42:25";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:12:25", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-18 19:12:25', '2', 'showallajax', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:42:30";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:12:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-18 19:12:30', '2', 'showallajax', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:42:33";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:12:33", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-18 19:12:33', '2', 'showallajax', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:42:37";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:12:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-18 19:12:37', '2', 'showallajax', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:42:41";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:12:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-18 19:12:41', '2', 'showallajax', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:42:45";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:12:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-18 19:12:45', '2', 'showallajax', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:42:53";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:12:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-18 19:12:53', '2', 'showallajax', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:43:00";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:13:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-18 19:13:00', '2', 'showallajax', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:43:32";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:13:32", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-18 19:13:32', '2', 'showallajax', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php?do=showallajax');
UPDATE user SET loginip = "" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:45:50";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 19:15:50", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:15:50', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:46:00";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 19:16:00", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:16:00', '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-18 15:46:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:16:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:16:07', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:46:16";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 19:16:17", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:16:17', '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 = 101;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:47:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:17:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:17:05', '104', 'add', '192.168.1.13', '', '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', 'مشال', '', '25', '2024-12-18', '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 = '12895',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('12920.00','25', '1', '1', 'إضافة مصروف', '25834', '12895', '2024-12-18 19:17:05', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'مشال', expensesdetails = '', expensesValue = '25.00', expensesdate = '2024-12-18', 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 = '25834';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:47:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:17:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:17:05', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:47:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:17:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:17:07', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:47:44";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:17:44", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:17:44', '104', 'showDetail', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150120');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:47:58";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:17:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-18 19:17:58', '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-18 15:49:03";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:19:03", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 19:19:03', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:49:12";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:19:12", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 19:19:12', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:49:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:19:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 19:19:49', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:50:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:20:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 19:20:45', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:51:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:21:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 19:21:09', '104', 'add', '192.168.1.13', '', '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', '10000', '2024-12-18', '104', '0', '0','','1','1','0','0','10000');
UPDATE save SET  savecurrentvalue = '2895',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('12895.00','10000', '1', '1', 'تحويل امول الى الخزنة  [ شيكات وكمبيالات ] ', '3527', '2895', '2024-12-18 19:21:09', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '645000',  userid = '104' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('635000.00','10000', '0', '8', 'تحويل امول من الخزنة  [ نقدي ] ', '3527', '645000', '2024-12-18 19:21:09', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '8', transfermoneyvalue = '10000.00', transfermoneydate = '2024-12-18', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='10000' WHERE transfermoneyid = '3527';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:51:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:21:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 19:21:09', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:51:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:21:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 19:21:11', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:51:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:21:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 19:21:13', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:52:32";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:22:32", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:22:32', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:52:43";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:22:43", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:22:43', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:53:33";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:23:33", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:23:33', '77', 'showDetail', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150104');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:54:32";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:24:32", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 19:24:32', '77', 'oneSupplier', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:54:35";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:24:35", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:24:35', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:54:48";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:24:48", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:24:48', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:55:02";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:25:02", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:25:02', '77', 'showDetail', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150104');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:55:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:25:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:25:40', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:55:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:25:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 19:25:48', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:55:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:25:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 19:25:57', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:56:34";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:26:34", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 19:26:34', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:57:09";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:27:09", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 19:27:09', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:57:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:27:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 19:27:19', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:57:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:27:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 19:27:22', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:57:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:27:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:27:59', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:58:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:28:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:28:10', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:58:31";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:28:31", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 19:28:31', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 15:58:41";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:28:41", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 19:28:41', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:00:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:30:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:30:13', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:01:55";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:31:55", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:31:55', '77', 'showDetail', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150094');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:01:56";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:31:56", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:31:56', '77', 'showDetail', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150101');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:02:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:32:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 19:32:01', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:04:03";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:34:03", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:34:03', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:04:11";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:34:11", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:34:11', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:04:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:34:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:34:17', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:04:19";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:34:19", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:34:19', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:04:44";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:34:44", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:34:44', '77', 'showDetail', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150112');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:05:33";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:35:33", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:35:33', '77', 'showDetail', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150112');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:05:46";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:35:46", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 19:35:46', '77', 'oneSupplier', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:06:07";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:36:07", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:36:07', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:06:15";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:36:15", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:36:15', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:06:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:36:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 19:36:22', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:06:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:36:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 19:36:24', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:06:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:36:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 19:36:25', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:08:14";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:38:14", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:38:14', '77', 'showDetail', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150051');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:08:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:38:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:38:29', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:08:37";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:38:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:38:37', '104', 'add', '192.168.1.13', '', '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-18', '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 = '2890',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2895.00','5', '1', '1', 'إضافة مصروف', '25835', '2890', '2024-12-18 19:38:37', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'نفحة', expensesdetails = '', expensesValue = '5.00', expensesdate = '2024-12-18', 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 = '25835';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:08:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:38:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:38:38', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:08:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:38:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 19:38:39', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:08:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:38:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 19:38:42', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:11:31";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:41:31", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:41:31', '77', 'showDetail', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150051');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:11:33";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:41:33", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 19:41:33', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:11:36";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:41:36", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 19:41:36', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:11:43";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:41:43", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 19:41:43', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:12:28";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:42:28", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:42:28', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:12:40";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:42:40", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:42: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-18 16:13:02";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:43:02", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-18 19:43:02', '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-18 16:13:52";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:43:52", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 19:43:52', '77', 'oneSupplier', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:13:54";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:43:54", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:43:54', '77', '', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:14:03";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:44:03", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:44:03', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:14:14";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:44:14", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-18 19:44:14', '77', 'showDetail', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=showDetail&sellbillid=113');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:14:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:44:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:44:17', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:14:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:44:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:44:32', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:14:34";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:44:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:44:34', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:15:07";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 19:45:07", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-18 19:45:07', '77', 'showDetail', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=showDetail&sellbillid=113');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:15:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:45:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-18 19:45:12', '104', 'showDetail', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=showDetail&sellbillid=113');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:15:13";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:45:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:45:13', '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-18 16:15:20";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:45:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:45:20', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=147490');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:16:05";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:46:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:46:05', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:16:21";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:46:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:46:21', '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-18 16:16:25";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:46:25", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:46:25', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149934');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:17:21";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:47:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-18 19:47:21', '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-18 16:18:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:48:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:48:18', '104', 'showDetail', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150010');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:20:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:50:14", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:50:14', '77', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:20:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:50:41", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-18 19:50:41', '77', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:20:58";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:50:58", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-18 19:50:58', '77', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:21:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:51:07", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 19:51:07', '77', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:21:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:51:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-18 19:51:50', '104', 'showDetail', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=showDetail&sellbillid=113');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:22:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:52:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:52:19', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:22:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:52:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:52:20', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:22:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:52:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:52:33', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE userid = 77;
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-18 16:24:27";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:54:28", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 19:54:28', '77', '', '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-18 16:24:29";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:25:00";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:55:00", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:55:00', '77', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:25:20";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:55:20", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:55:20', '77', '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-18 16:25:31";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:55:31", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-18 19:55:31', '77', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=showDetail&sellbillid=113');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:25:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:55:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:55:32', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067630be166576
-- ----------------------------------------------------------------------------------------------------

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-18 19:52:33', '067630be166576', '1', '0.00', '0', '0', '1', '1550.00', '1550', '1550', '0', '1', '2024-12-18 19:55:32', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1550','0','','0','0','1550','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150129', '0', '2024-12-18 19:55:32', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1550', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 19:52:33','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', '150129', '1', '16440', '1', '470', '470', '0', '', '1', '2024-12-18 19:55:32', '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 = 548505;
 INSERT INTO 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-18', 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-18', 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 = '49', userid = '104', storedetaildate = '2024-12-18 19:55:32' WHERE storedetailid = '16439';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16440', '1', '1', '1', '150129', 'اضافة فاتورة مبيعات', 'sellbillController.php', '50', '49', '104', '2024-12-18 19:55:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35870;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3324', '150129', '1', '16274', '1', '500', '500', '0', '', '1', '2024-12-18 19:55:32', '16274', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35870-1,','1','1','0','0','500','500','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 = 548506;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16274, '2024-12-18', 500, 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+500, 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-18', 500, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, 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 = '104', storedetaildate = '2024-12-18 19:55:32' WHERE storedetailid = '16273';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16274', '1', '1', '1', '150129', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '104', '2024-12-18 19:55:32','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35910;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150129', '5', '16297', '1', '580', '580', '0', '', '1', '2024-12-18 19:55:32', '16297', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35910-1,','1','1','0','0','580','580','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 = 548507;
 INSERT INTO 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-18', 580, 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+580, 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-18', 580, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0, 510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, 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 = '92', userid = '104', storedetaildate = '2024-12-18 19:55:32' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '1', '150129', 'اضافة فاتورة مبيعات', 'sellbillController.php', '93', '92', '104', '2024-12-18 19:55:32','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '4440',  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 ('2890','1550', '0', '1', 'اضافة فاتورة مبيعات', '150129', '4440', '2024-12-18 19:55:32', '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-18', 1550, 1310, 1310
                    , 1310, 1310, 1310, 1310
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1310, 1310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1550, sellCostBuyPrice =sellCostBuyPrice+1310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1550, 1310, 1310
                    , 1310, 1310, 1310, 1310
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1310, 1310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1550, sellCostBuyPrice =sellCostBuyPrice+1310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1550, 1310, 1310
                    , 1310, 1310, 1310, 1310, 1310, 1310)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1550, netSellCostBuyPrice = netSellCostBuyPrice+1310
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1310
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1310
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1310
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1310
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1310
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1310
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1310;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067630be166576 and sellbillId = 150129 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:25:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:55:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:55:33', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:26:32";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:56:32", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:56:32', '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-18 16:26:43";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:56:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:56:43', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150080');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:27:08";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:57:08", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:57:08', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067630c95850c5
-- ----------------------------------------------------------------------------------------------------

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-18 19:55:33', '067630c95850c5', '1', '0.00', '0', '0', '1', '350.00', '350', '350', '0', '1', '2024-12-18 19:57:08', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','350','0','','0','0','350','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150130', '0', '2024-12-18 19:57:08', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '350', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 19:55:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34917;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06925', '150130', '5', '15785', '1', '350', '350', '0', '', '1', '2024-12-18 19:57:08', '15785', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34917-1,','1','1','0','0','350','350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 275.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 275.00
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 270, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 548508;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15785, '2024-12-18', 350, 280, 280
                    , 275, 280, 275, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 280, 270, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+275
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+275
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+270
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 350, 280, 280
                    , 275, 280, 275, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 270, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+275
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+275
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+270
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 19:57:08' WHERE storedetailid = '15784';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15785', '1', '1', '1', '150130', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-18 19:57:08','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '4790',  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 ('4440','350', '0', '1', 'اضافة فاتورة مبيعات', '150130', '4790', '2024-12-18 19:57:08', '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-18', 350, 280, 280
                    , 275, 280, 275, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 270, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+275
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+275
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+270
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 350, 280, 280
                    , 275, 280, 275, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 270, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+275
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+275
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+270
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 350, 280, 280
                    , 275, 280, 275, 270, 280, 270)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+350, netSellCostBuyPrice = netSellCostBuyPrice+280
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+275
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+275
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+270
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+280
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+270;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067630c95850c5 and sellbillId = 150130 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:27:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:57:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:57:09', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:27:33";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:57:33", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:57:33', '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-18 16:27:38";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:57:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:57:38', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150061');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:28:16";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:58:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:58: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-18 16:28:20";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:58:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:58:20', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150114');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:28:47";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:58:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 19:58:47', '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-18 16:28:52";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 19:58:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:58:52', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150107');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:29:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:59:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:59:11', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067630cf5947fa
-- ----------------------------------------------------------------------------------------------------

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-18 19:57:09', '067630cf5947fa', '1', '0.00', '0', '0', '1', '1900.00', '1900', '1900', '0', '1', '2024-12-18 19:59:11', '', '104', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','1900','0','','0','0','1900','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150131', '0', '2024-12-18 19:59:11', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1900', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 19:57:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35299;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1358', '150131', '14', '15474', '1', '620', '620', '0', '', '1', '2024-12-18 19:59:11', '15474', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35299-1,','1','1','0','0','620','620','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 = 462, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 548509;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15474, '2024-12-18', 620, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 500, 462, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+462
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 620, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 462, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+500
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+462
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 19:59:12' WHERE storedetailid = '15473';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15474', '1', '1', '1', '150131', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-18 19:59:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34548;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06883', '150131', '5', '15661', '1', '210', '210', '0', '', '1', '2024-12-18 19:59:12', '15661', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34548-1,','1','1','0','0','210','210','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 = 548510;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15661, '2024-12-18', 210, 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+210, 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-18', 210, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 160, 160, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, 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 = '6', userid = '104', storedetaildate = '2024-12-18 19:59:12' WHERE storedetailid = '15660';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15661', '1', '1', '1', '150131', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-18 19:59:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36171;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1409', '150131', '14', '15689', '1', '570', '570', '0', '', '1', '2024-12-18 19:59:12', '15689', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36171-1,','1','1','0','0','570','570','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 = 548511;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15689, '2024-12-18', 570, 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+570, 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-18', 570, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0, 490, 490, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+570, 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 = '6', userid = '104', storedetaildate = '2024-12-18 19:59:12' WHERE storedetailid = '15688';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15689', '1', '1', '1', '150131', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-18 19:59:12','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', '150131', '1', '16440', '1', '500', '500', '0', '', '1', '2024-12-18 19:59:12', '16440', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36373-1,','1','1','0','0','500','500','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 = 548512;
 INSERT INTO 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-18', 500, 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+500, 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-18', 500, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, 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 = '48', userid = '104', storedetaildate = '2024-12-18 19:59:12' WHERE storedetailid = '16439';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16440', '1', '1', '1', '150131', 'اضافة فاتورة مبيعات', 'sellbillController.php', '49', '48', '104', '2024-12-18 19:59:12','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6690',  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 ('4790','1900', '0', '1', 'اضافة فاتورة مبيعات', '150131', '6690', '2024-12-18 19:59:12', '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-18', 1900, 1550, 1550
                    , 1550, 1550, 1550, 1550
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1550, 1512, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1900, sellCostBuyPrice =sellCostBuyPrice+1550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1512
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-18', 1900, 1550, 1550
                    , 1550, 1550, 1550, 1550
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1550, 1512, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1900, sellCostBuyPrice =sellCostBuyPrice+1550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1512
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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, 1900, 1550, 1550
                    , 1550, 1550, 1550, 1550, 1550, 1512)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1900, netSellCostBuyPrice = netSellCostBuyPrice+1550
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1550
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1550
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1550
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1550
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1550
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1550
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1512;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067630cf5947fa and sellbillId = 150131 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:29:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 19:59:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:59:12', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:29:52";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 19:59:52", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 19:59:52', '77', '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-18 16:30:16";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:00:16", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:00:16', '77', '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-18 16:30:31";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 20:00:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 20:00:31', '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-18 16:30:37";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 20:00:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:00:37', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=142652');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:30:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:00:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:00:51', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067630d70e9763
-- ----------------------------------------------------------------------------------------------------

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-18 19:59:12', '067630d70e9763', '1', '0.00', '0', '0', '1', '1260.00', '1260', '1260', '0', '1', '2024-12-18 20:00:51', '', '104', '0', 'نقدي', '1', '0', '3', '26', 'نقدي', '1' ,'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-18','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','اضافة فاتورة مبيعات','150132', '0', '2024-12-18 20:00:51', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1260', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 19:59:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35068;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('920','H1447', '150132', '14', '15803', '1', '1260', '1260', '0', '', '1', '2024-12-18 20:00:51', '15803', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35068-1,','1','1','0','0','1260','1260','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 920.00 , meanbuyprice = 926.00, lastbuyprice_withDiscount = 920.00, meanbuyprice_withDiscount = 926.00
        , lastbuyprice_withTax = 920, meanbuyprice_withTax = 931, lastbuyprice_withDiscountAndTax = 920
                where sellbilldetailid = 548513;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15803, '2024-12-18', 1260, 920, 920
                    , 926, 920, 926, 935
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 920, 931, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1260, sellCostBuyPrice =sellCostBuyPrice+920
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+920, sellCostMeanBuyPrice = sellCostMeanBuyPrice+926
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+920, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+926
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+935
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+920
                            , 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
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 1260, 920, 920
                    , 926, 920, 926, 935
                    , 0, 0, 0, 0
                    , 0, 0, 0, 920, 931, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1260, sellCostBuyPrice =sellCostBuyPrice+920
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+920, sellCostMeanBuyPrice = sellCostMeanBuyPrice+926
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+920, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+926
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+935
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+920
                            , 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;
UPDATE storedetail SET  productquantity = '5', userid = '104', storedetaildate = '2024-12-18 20:00:51' WHERE storedetailid = '15802';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15803', '1', '1', '1', '150132', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-18 20:00:51','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '7950',  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 ('6690','1260', '0', '1', 'اضافة فاتورة مبيعات', '150132', '7950', '2024-12-18 20:00:51', '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-18', 1260, 920, 920
                    , 926, 920, 926, 935
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,920, 931, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1260, sellCostBuyPrice =sellCostBuyPrice+920
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+920, sellCostMeanBuyPrice = sellCostMeanBuyPrice+926
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+920, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+926
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+935
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+920
                            , 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-18', 1260, 920, 920
                    , 926, 920, 926, 935
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,920, 931, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1260, sellCostBuyPrice =sellCostBuyPrice+920
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+920, sellCostMeanBuyPrice = sellCostMeanBuyPrice+926
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+920, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+926
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+935
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+920
                            , 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, 1260, 920, 920
                    , 926, 920, 926, 935, 920, 931)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1260, netSellCostBuyPrice = netSellCostBuyPrice+920
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+920
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+926
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+920
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+926
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+935
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+920
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+931;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067630d70e9763 and sellbillId = 150132 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:30:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:00:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:00:52', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:31:00";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 20:01:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-18 20:01: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-18 16:32:23";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 20:02:23", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 20:02:23', '2', '', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:32:36";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 20:02:36", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 20:02:36', '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-18 16:32:43";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:02:43", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:02:43', '77', '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-18 16:32:43";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 20:02:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:02:43', '2', 'showDetail', '192.168.1.165', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149760');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:36:05";
UPDATE user SET loginip = "192.168.1.165", lastactivetime = "2024-12-18 20:06:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 20:06:05', '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-18 16:38:00";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:08:00", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:08:00', '77', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150053');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:42:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:12:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:12:20', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067630dd4a0622
-- ----------------------------------------------------------------------------------------------------

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-18 20:00:52', '067630dd4a0622', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2024-12-18 20:12:20', '', '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-18','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','اضافة فاتورة مبيعات','150133', '0', '2024-12-18 20:12:20', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 20:00:52','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36056;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '150133', '5', '16348', '1', '200', '200', '0', '', '1', '2024-12-18 20:12:20', '16348', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36056-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 = 548514;
 INSERT INTO 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-18', 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-18', 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 = '34', userid = '104', storedetaildate = '2024-12-18 20:12:20' WHERE storedetailid = '16347';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16348', '1', '1', '1', '150133', 'اضافة فاتورة مبيعات', 'sellbillController.php', '35', '34', '104', '2024-12-18 20:12:20','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '8150',  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 ('7950','200', '0', '1', 'اضافة فاتورة مبيعات', '150133', '8150', '2024-12-18 20:12:20', '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-18', 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;
 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-18', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 200, 140, 140
                    , 139, 140, 139, 140, 140, 139)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+200, netSellCostBuyPrice = netSellCostBuyPrice+140
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+140
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+139
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+140
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+139
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+140
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+140
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+139;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067630dd4a0622 and sellbillId = 150133 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:42:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:12:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:12:21', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:42:50";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:12:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 20:12:50', '77', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:43:57";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:13:57", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 20:13:57', '77', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:44:10";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:14:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 20:14:10', '77', '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-18 16:44:57";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:14:57", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 20:14:57', '77', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.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-18 16:45:16";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:15:16", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 20:15:16', '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-18 16:45:16";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:45:35";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:15:35", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 20:15:35', '77', '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-18 16:45:54";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:15:54", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 20:15:54', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:46:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:16:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 20:16:11', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:46:17";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:16:18", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 20:16: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-18 16:46:22";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:16:22", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:16:22', '101', 'showDetail', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149704');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:46:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:16:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 20:16:29', '104', 'add', '192.168.1.13', '', '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-18', '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 = '7850',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8150.00','300', '1', '1', 'إضافة مصروف', '25836', '7850', '2024-12-18 20:16:29', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'عبدة حسابات', expensesdetails = '', expensesValue = '300.00', expensesdate = '2024-12-18', 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 = '25836';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:46:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:16:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 20:16:30', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:46:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:16:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 20:16:32', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:46:52";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:16:52", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:16:52', '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-18 16:46:58";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:16:58", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:16:58', '77', '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-18 16:47:10";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:17:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:17:10', '77', '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-18 16:47:55";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:17:55", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 20:17: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-18 16:48:01";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:18:01", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:18:01', '101', 'showDetail', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149129');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:48:32";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:18:32", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:18:32', '77', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150051');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:51:42";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:21:42", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 20:21:42', '77', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:52:05";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:22:05", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-18 20:22:05', '77', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:52:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:22:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:22:10', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:53:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:23:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:23:14', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE userid = 77;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:53:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:23:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:23:41', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067631312ad627
-- ----------------------------------------------------------------------------------------------------

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-18 20:23:14', '067631312ad627', '1', '0.00', '0', '0', '1', '1100', '1100', '-1100', '0', '1', '2024-12-18 20:23:41', '', '104', '0', 'نقدي','1', '0', '5', '4', 'نقدي', '2', '0', '', '','','','-1','0','0','0','','0','-1100','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','اضافة فاتورة مردوات مبيعات','16822', '0', '2024-12-18 20:23:41', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '1100', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 20:23:14','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 ('510.00', 'H1579', '16822', '14', '16197', '2', '550', '1100', '0', '', '1', '0', '16197', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','550','1100','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 510.00 , meanbuyprice = 509.00, lastbuyprice_withDiscount = 510.00, meanbuyprice_withDiscount = 509.00
        , lastbuyprice_withTax = 510, meanbuyprice_withTax = 508, lastbuyprice_withDiscountAndTax = 510
                where returnsellbilldetailid = 22005;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16197, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1100, 1020, 1020, 1018
                    , 1020, 1018, 1000, 0, 2, 0, 0, 1020, 1016)
                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+1100, returnSellCostBuyPrice = returnSellCostBuyPrice+1020, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1020
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1018, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1020
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1018
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+1000
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+1020
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+1016
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+2;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1100, 1020, 1020, 1018
                    , 1020, 1018, 1000, 0, 0, 1020, 1016)
                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+1100, returnSellCostBuyPrice = returnSellCostBuyPrice+1020, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1020
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1018, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1020
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1018
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+1000
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+1020
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+1016;
UPDATE storedetail SET  productquantity = '11', userid = '104', storedetaildate = '2024-12-18 20:23:41' WHERE storedetailid = '16196';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16197', '1', '2', '0', '16822', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '9', '11', '104', '2024-12-18 20:23:41','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6750',  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 ('7850','-1100', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16822', '6750', '2024-12-18 20:23:41', '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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1100, 1020, 1020, 1018
                    , 1020, 1018, 1000 ,0, 0, 1020, 1016)
                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+1100, returnSellCostBuyPrice = returnSellCostBuyPrice+1020, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1020
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1018, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1020
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1018
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+1000
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+1020
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+1016;
 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1100, 1020, 1020, 1018
                    , 1020, 1018, 1000 ,0, 0, 1020, 1016)
                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+1100, returnSellCostBuyPrice = returnSellCostBuyPrice+1020, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1020
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1018, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1020
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1018
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+1000
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+1020
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+1016;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -1100, -1020, -1020
                    , -1018, -1020, -1018, -1000, -1020, -1016)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-1100, netSellCostBuyPrice = netSellCostBuyPrice+-1020
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-1020
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-1018
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-1020
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-1018
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-1000
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-1020
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-1016;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 067631312ad627 and sellbillId = 16822 and returnsellbillId = 16822
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:53:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:23:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:23:42', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:53:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:23:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:23:51', '104', 'addsellBill', '192.168.1.13', '', '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-18 16:54:12";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:24:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 20:24:13', '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-18 16:54:13";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:54:23";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:24:23", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:24: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-18 16:54:28";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:24:28", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-18 20:24:28', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:54:29";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:24:29", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-18 20:24: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-18 16:54:31";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:24:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-18 20:24:31', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:54:39";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:24:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:24:39', '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-18 16:54:48";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:24:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-18 20:24:48', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:54:58";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:24:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-18 20:24: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-18 16:55:08";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:25:08", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-18 20:25: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-18 16:56:32";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:26:32", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 20:26:32', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:56:36";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:26:36", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 20:26:36', '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-18 16:58:08";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:28:08", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:28:08', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:58:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:28:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:28:10', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:58:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:28:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:28:30', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06763143b04f5d
-- ----------------------------------------------------------------------------------------------------

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-18 20:28:11', '06763143b04f5d', '1', '0.00', '0', '0', '1', '275', '275', '-275', '0', '1', '2024-12-18 20:28:30', '', '104', '0', 'نقدي','1', '0', '5', '3', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-275','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','اضافة فاتورة مردوات مبيعات','16823', '0', '2024-12-18 20:28:30', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '275', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 20:28: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 ('280.00', '0H812', '16823', '14', '8814', '1', '275', '275', '0', '', '1', '0', '8814', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','275','275','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        
                where returnsellbilldetailid = 22006;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8814, '2024-12-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 275, 280, 280, 280
                    , 280, 280, 280, 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+275, returnSellCostBuyPrice = returnSellCostBuyPrice+280, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+280
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+280, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+280
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+280
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+280
                            , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 275, 280, 280, 280
                    , 280, 280, 280, 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+275, returnSellCostBuyPrice = returnSellCostBuyPrice+280, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+280
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+280, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+280
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+280
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+280
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '104', storedetaildate = '2024-12-18 20:28:30' WHERE storedetailid = '8813';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('8814', '1', '1', '0', '16823', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '-1', '0', '104', '2024-12-18 20:28:30','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6475',  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','-275', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16823', '6475', '2024-12-18 20:28:30', '104',  'returnsellbillController.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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 275, 280, 280, 280
                    , 280, 280, 280 ,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+275, returnSellCostBuyPrice = returnSellCostBuyPrice+280, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+280
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+280, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+280
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+280
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+280
                            , 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-18', 0, 0, 0
                    , 0, 0, 0, 0
                    , 275, 280, 280, 280
                    , 280, 280, 280 ,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+275, returnSellCostBuyPrice = returnSellCostBuyPrice+280, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+280
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+280, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+280
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+280
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+280
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -275, -280, -280
                    , -280, -280, -280, -280, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-275, netSellCostBuyPrice = netSellCostBuyPrice+-280
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-280
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-280
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-280
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06763143b04f5d and sellbillId = 16823 and returnsellbillId = 16823
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:58:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:28:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:28:30', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:59:28";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:29:29", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:29:29', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:59:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:29:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:29:46', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676312d31ec48
-- ----------------------------------------------------------------------------------------------------

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-18 20:22:11', '0676312d31ec48', '1', '0.00', '0', '0', '1', '585.00', '585', '585', '0', '1', '2024-12-18 20:29:46', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','585','0','','0','0','585','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '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','اضافة فاتورة مبيعات','150134', '0', '2024-12-18 20:29:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '585', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 20:22:11','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', '150134', '5', '13754', '1', '385', '385', '0', '', '1', '2024-12-18 20:29:46', '13754', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30598-1,','1','1','0','0','385','385','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 = 548515;
 INSERT INTO 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-18', 385, 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+385, 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-18', 385, 445, 445
                    , 445, 445, 445, 445
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+385, 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 = '2', userid = '104', storedetaildate = '2024-12-18 20:29:46' WHERE storedetailid = '13753';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13754', '1', '1', '1', '150134', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '104', '2024-12-18 20:29:46','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', '150134', '5', '16347', '1', '200', '200', '0', '', '1', '2024-12-18 20:29:46', '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 = 548516;
 INSERT INTO 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-18', 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-18', 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 = '11', userid = '104', storedetaildate = '2024-12-18 20:29:46' WHERE storedetailid = '16346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16347', '1', '1', '1', '150134', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-18 20:29:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '7060',  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 ('6475','585', '0', '1', 'اضافة فاتورة مبيعات', '150134', '7060', '2024-12-18 20:29: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-18', 585, 585, 585
                    , 582, 585, 582, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 134, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+585, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+582
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+582
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+585
                            , 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;
 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-18', 585, 585, 585
                    , 582, 585, 582, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 134, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+585, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+582
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+582
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+585
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 585, 585, 585
                    , 582, 585, 582, 585, 140, 134)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+585, netSellCostBuyPrice = netSellCostBuyPrice+585
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+585
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+582
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+585
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+582
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+585
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+140
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+134;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0676312d31ec48 and sellbillId = 150134 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 16:59:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:29:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:29:47', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:00:01";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:30:01", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 20:30:01', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:00:11";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:30:11", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 20:30:11', '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-18 17:00:16";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:30:16", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:30:16', '101', 'showDetail', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149760');
UPDATE user SET loginip = "" WHERE userid = 77;
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;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:00:50";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:30:51", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 20:30:51', '77', '', '192.168.1.21', '', '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-18 17:00:52";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:00:57";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:30:57", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:30:57', '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-18 17:01:07";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:31:07", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:31:07', '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-18 17:01:14";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:31:14", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:31:14', '101', 'editsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=149760');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:01:28";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:31:28", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:31:28', '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 = 149760 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


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

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 149760;
UPDATE sellbill SET  sellbillsysdate = '2024-12-18 20:31:29', userid = '75',delbyuserid = '101', conditions = '1'  WHERE sellbillid = '149760';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35923;
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 = 547012;
 INSERT INTO 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-18', 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-18', 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 = '38', userid = '101', storedetaildate = '2024-12-18 20:31:29' WHERE storedetailid = '16299';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16300', '1', '1', '0', '149760', 'تعديل فاتورة مبيعات', 'sellbillController.php', '37', '38', '101', '2024-12-16 18:37:25','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 = 547013;
 INSERT INTO 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-18', 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-18', 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 = '35', userid = '101', storedetaildate = '2024-12-18 20:31:29' WHERE storedetailid = '15966';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15967', '1', '1', '0', '149760', 'تعديل فاتورة مبيعات', 'sellbillController.php', '34', '35', '101', '2024-12-16 18:37:25','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 33152;
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 257.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 257.00
        
                where sellbilldetailid = 547014;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14833, '2024-12-18', 290, 260, 260
                    , 257, 260, 257, 256.36
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-290, sellCostBuyPrice =sellCostBuyPrice-260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-260, sellCostMeanBuyPrice = sellCostMeanBuyPrice-257
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-257
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-256.36
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 290, 260, 260
                    , 257, 260, 257, 256.36
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-290, sellCostBuyPrice =sellCostBuyPrice-260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-260, sellCostMeanBuyPrice = sellCostMeanBuyPrice-257
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-257
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-256.36
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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 = '101', storedetaildate = '2024-12-18 20:31:29' WHERE storedetailid = '14832';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14833', '1', '1', '0', '149760', 'تعديل فاتورة مبيعات', 'sellbillController.php', '18', '19', '101', '2024-12-16 18:37:25','0','0');
CALL clientInUse(295,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-520', userid = '101' WHERE clientid = '295';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('295','359.00','879.00','1','تعديل فاتورة مبيعات','149760', '-520', '2024-12-16 18:37:25', '101', 'sellbillController.php', 'تعديل فاتورة مبيعات', '879', '0', null, '0', null, null,'', '0','1','1','879','1','2024-12-16 18:37:25','0','0');
UPDATE client SET  inUse = 0 where clientid = 295;
 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-18', 879, 695, 695
                    , 692, 695, 692, 691.36
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,435, 435, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-879, sellCostBuyPrice =sellCostBuyPrice-695
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-695, sellCostMeanBuyPrice = sellCostMeanBuyPrice-692
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-695, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-692
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-691.36
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-435
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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 (295, '2024-12-18', 879, 695, 695
                    , 692, 695, 692, 691.36
                    , 0, 0, 0, 0
                    , 0, 0, 0, 435, 435, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-879, sellCostBuyPrice =sellCostBuyPrice-695
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-695, sellCostMeanBuyPrice = sellCostMeanBuyPrice-692
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-695, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-692
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-691.36
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-435
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-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, 879, 695, 695
                    , 692, 695, 692, 691.36, 435, 435)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-879, netSellCostBuyPrice = netSellCostBuyPrice-695
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-695
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-692
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-695
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-692
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-691.36
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-435
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-435;

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


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

COMMIT;
BEGIN;
CALL clientInUse(295,@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-16 18:37:25', '0676057455172b', '295', '-520.00', '-1', '0', '1', '519', '519', '0', '519', '1', '2024-12-16 18:37:25', '', '101', '0', 'ايمن ميتشو y42', '2', '1', '3', '85', 'ايمن ميتشو y42', '4', '149760', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-16','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '-1', userid = '101' WHERE clientid = '295';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('295','-520.00','519','0','اضافة فاتورة مبيعات (معدله)','150135', '-1', '2024-12-18 20:31:29', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '519', '0', null, '0', null, null,'', '0','1','1','879','1','2024-12-16 18:37:25','0','0');
UPDATE client SET  inUse = 0 where clientid = 295;
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', '150135', '5', '16300', '1', '200', '200', '0', '', '1', '2024-12-18 20:31:29', '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 = 548517;
 INSERT INTO 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-18', 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-18', 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 = '37', userid = '101', storedetaildate = '2024-12-18 20:31:29' WHERE storedetailid = '16299';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16300', '1', '1', '1', '150135', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '38', '37', '101', '2024-12-18 20:31:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33152;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3078', '150135', '1', '14833', '1', '290', '290', '0', '', '1', '2024-12-18 20:31:29', '14833', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33152-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 257.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 257.00
        
                where sellbilldetailid = 548518;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14833, '2024-12-18', 290, 260, 260
                    , 257, 260, 257, 256.36
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+257
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+257
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+256.36
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-18', 290, 260, 260
                    , 257, 260, 257, 256.36
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+257
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+257
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+256.36
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-18 20:31:29' WHERE storedetailid = '14832';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14833', '1', '1', '1', '150135', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '19', '18', '101', '2024-12-18 20:31: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', '150135', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-18 20:31: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', '150135', '17', '10291', '1', '9', '9', '0', '', '1', '2024-12-18 20:31:29', '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');
 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-18', 519, 400, 400
                    , 397, 400, 397, 396.36
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+519, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+397
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+397
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+396.36
                            , 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 (295, '2024-12-18', 519, 400, 400
                    , 397, 400, 397, 396.36
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+519, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+397
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+397
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+396.36
                            , 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, 519, 400, 400
                    , 397, 400, 397, 396.36, 140, 140)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+519, netSellCostBuyPrice = netSellCostBuyPrice+400
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+400
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+397
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+400
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+397
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+396.36
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+140
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+140;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 149760 and newid=150135 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:01:29";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-18 20:31:29", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:31:29', '101', 'editprint', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=150135');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:01:39";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:31:39", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:31:39', '77', 'bill', '192.168.1.21', '', '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 ('H1692','','14','400','550', '550','550', '2024-12-18', '0', '77', '1', 'H1692', '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 (16504, 1,'2024-12-18 20:32:11',77)
                ON DUPLICATE KEY UPDATE productid = 16504, edited = 1, sysdate = '2024-12-18 20:32:11', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16504', '1', '2024-12-18', '77', '0','1650401','550','550','550','400','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16504', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16504', '1', '0', '0', '16504', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:02:18";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:32:18", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:32:18', '77', 'add', '192.168.1.21', '', '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 ('06763150c219a1', '2024-12-18 20:31:40', '6', '316230.00', '320230', '0', '0', '4000',  '4000', '0', '4000', '1', '2024-12-18 20:32:19', '', '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 ('H1692', '14157', '14', '16504', '10', '400', '4000', '0', '', '2024-12-18 20:32:19', '16504','','','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-18 20:31:40', 1, 16504, 0, 0
                    , 400, 10, 0, 0, 77, '2024-12-18 20:32:19')
                ON DUPLICATE KEY UPDATE buyprice = 400,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 20:32:19' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16504', '400', '10', '0', 'buyBillController.php', '32763', '', '0', '0');
UPDATE product SET  productBuyPrice = "400" WHERE productId = 16504 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32763 ;
UPDATE product SET productName = 'H1692', productDescription = '', productCatId = '14', productBuyPrice = '400.00', productSellAllPrice = '550.00', productSellUnitPrice = '550.00', productSellHalfPrice = '550.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1692',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 = '16504';
UPDATE buybilldetail SET  lastbuyprice = 400 , meanbuyprice = 400, lastbuyprice_withDiscount = 400, meanbuyprice_withDiscount = 400
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where buybilldetailid = 32763;
UPDATE productunit SET proUnitBuyPrice  = 400 * productnumber WHERE productid = 16504;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16503';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16504', '1', '10', '0', '14157', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-18 20:31:40','0','0');
UPDATE supplier SET  suppliercurrentDebt = '320230',suppliercurrentDebtInCurrency= '320230' , userid = '77', supplierdate = '2024-12-18 20:32:19'   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', '316230.00', '4000', '0', 'اضافة فاتورة مشتريات', '14157', '320230', '2024-12-18 20:31:40', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','4000','1','316230','4000','320230','0');
update buybill set dailyentryid='0,' where buybillid=14157;
COMMIT;
UPDATE product SET overAllAveragePrice = 400 WHERE productId = 16504;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:02:19";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:32:19", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:32:19', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14157');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:02:23";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:32:23", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 20:32:23', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14157&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:03:14";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:33:14", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 20:33:14', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14157&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:05:53";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:35:53", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:35:53', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:06:14";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:36:14", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:36:14', '77', 'add', '192.168.1.21', '', '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 ('067631609a38b2', '2024-12-18 20:35:53', '235', '36205.00', '37855', '0', '0', '1650',  '1650', '0', '1650', '1', '2024-12-18 20:36:14', '', '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', '14158', '1', '16399', '15', '110', '1650', '0', '', '2024-12-18 20:36:14', '16399','','','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-18 20:35:53', 1, 16399, 0, 0
                    , 110, 15, 0, 0, 77, '2024-12-18 20:36:14')
                ON DUPLICATE KEY UPDATE buyprice = 110,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 20:36:14' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16399', '110', '15', '0', 'buyBillController.php', '32764', '', '0', '0');
UPDATE product SET  productBuyPrice = "110" WHERE productId = 16399 ;
UPDATE buybilldetail SET  quantitybefore = 9 WHERE buybilldetailid = 32764 ;
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 = 32764;
UPDATE productunit SET proUnitBuyPrice  = 110 * productnumber WHERE productid = 16399;
UPDATE storedetail SET  productquantity = '24', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16398';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16399', '1', '15', '0', '14158', 'اضافة فاتورة مشتريات', 'buyBillController.php', '9', '24', '77', '2024-12-18 20:35:53','0','0');
UPDATE supplier SET  suppliercurrentDebt = '37855',suppliercurrentDebtInCurrency= '37855' , userid = '77', supplierdate = '2024-12-18 20:36:14'   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', '36205.00', '1650', '0', 'اضافة فاتورة مشتريات', '14158', '37855', '2024-12-18 20:35:53', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','1650','1','36205','1650','37855','0');
update buybill set dailyentryid='0,' where buybillid=14158;
COMMIT;
UPDATE product SET overAllAveragePrice = 110 WHERE productId = 16399;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:06:15";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:36:15", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:36:15', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14158');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:06:21";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:36:21", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 20:36:21', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14158&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:06:34";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:36:34", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 20:36:34', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14158&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:06:36";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:36:36", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:36:36', '77', 'bill', '192.168.1.21', '', '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 ('H1690','','14','400','500', '500','500', '2024-12-18', '0', '77', '1', 'H1690', '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 (16505, 1,'2024-12-18 20:37:19',77)
                ON DUPLICATE KEY UPDATE productid = 16505, edited = 1, sysdate = '2024-12-18 20:37: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', '16505', '1', '2024-12-18', '77', '0','1650501','500','500','500','400','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16505', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16505', '1', '0', '0', '16505', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:07:31";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:37:31", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:37:31', '77', 'add', '192.168.1.21', '', '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 ('067631634801c9', '2024-12-18 20:36:36', '236', '18230.00', '30330', '0', '0', '12100',  '12100', '0', '12100', '1', '2024-12-18 20:37: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 ('H1663', '14159', '14', '16471', '10', '410', '4100', '0', '', '2024-12-18 20:37:32', '16471','','','0','0','0','0','0',null,'410','4100','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-18 20:36:36', 1, 16471, 0, 0
                    , 410, 10, 0, 0, 77, '2024-12-18 20:37:32')
                ON DUPLICATE KEY UPDATE buyprice = 410,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 20:37:32' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16471', '410', '10', '0', 'buyBillController.php', '32765', '', '0', '0');
UPDATE product SET  productBuyPrice = "410" WHERE productId = 16471 ;
UPDATE buybilldetail SET  quantitybefore = 16 WHERE buybilldetailid = 32765 ;
UPDATE product SET productName = 'H1663', productDescription = '', productCatId = '14', productBuyPrice = '410.00', productSellAllPrice = '500.00', productSellUnitPrice = '500.00', productSellHalfPrice = '500.00', productDate = '2024-12-14', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1663',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '410',lastbuyprice_withDiscount = '410',meanbuyprice = '410',meanbuyprice_withDiscount = '410' , productbuypricereal = '410.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='410',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='410',meanbuyprice_withTax='410',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='410'  WHERE productId = '16471';
UPDATE buybilldetail SET  lastbuyprice = 410 , meanbuyprice = 410, lastbuyprice_withDiscount = 410, meanbuyprice_withDiscount = 410
        , lastbuyprice_withTax = 410, meanbuyprice_withTax = 410, lastbuyprice_withDiscountAndTax = 410
                where buybilldetailid = 32765;
UPDATE productunit SET proUnitBuyPrice  = 410 * productnumber WHERE productid = 16471;
UPDATE storedetail SET  productquantity = '26', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16470';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16471', '1', '10', '0', '14159', 'اضافة فاتورة مشتريات', 'buyBillController.php', '16', '26', '77', '2024-12-18 20:36: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 ('H1690', '14159', '14', '16505', '20', '400', '8000', '0', '', '2024-12-18 20:37:32', '16505','','','0','0','0','0','0',null,'400','8000','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-18 20:36:36', 1, 16505, 0, 0
                    , 400, 20, 0, 0, 77, '2024-12-18 20:37:32')
                ON DUPLICATE KEY UPDATE buyprice = 400,
                        buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 20:37:32' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16505', '400', '20', '0', 'buyBillController.php', '32766', '', '0', '0');
UPDATE product SET  productBuyPrice = "400" WHERE productId = 16505 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32766 ;
UPDATE product SET productName = 'H1690', productDescription = '', productCatId = '14', productBuyPrice = '400.00', productSellAllPrice = '500.00', productSellUnitPrice = '500.00', productSellHalfPrice = '500.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1690',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 = '16505';
UPDATE buybilldetail SET  lastbuyprice = 400 , meanbuyprice = 400, lastbuyprice_withDiscount = 400, meanbuyprice_withDiscount = 400
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where buybilldetailid = 32766;
UPDATE productunit SET proUnitBuyPrice  = 400 * productnumber WHERE productid = 16505;
UPDATE storedetail SET  productquantity = '20', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16504';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16505', '1', '20', '0', '14159', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '20', '77', '2024-12-18 20:36:36','0','0');
UPDATE supplier SET  suppliercurrentDebt = '30330',suppliercurrentDebtInCurrency= '30330' , userid = '77', supplierdate = '2024-12-18 20:37:32'   WHERE supplierid = '236';
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 ('236', '18230.00', '12100', '0', 'اضافة فاتورة مشتريات', '14159', '30330', '2024-12-18 20:36:36', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','12100','1','18230','12100','30330','0');
update buybill set dailyentryid='0,' where buybillid=14159;
COMMIT;
UPDATE product SET overAllAveragePrice = 410 WHERE productId = 16471;UPDATE product SET overAllAveragePrice = 400 WHERE productId = 16505;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:07:32";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:37:32", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:37:32', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14159');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:07:35";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:37:35", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 20:37:35', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14159&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:12:02";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:42:02", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 20:42:02', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14159&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:12:04";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:42:04", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:42:04', '77', 'bill', '192.168.1.21', '', '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 ('R3352','','1','300','380', '380','380', '2024-12-18', '0', '77', '1', 'R3352', '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 (16506, 1,'2024-12-18 20:42:57',77)
                ON DUPLICATE KEY UPDATE productid = 16506, edited = 1, sysdate = '2024-12-18 20: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', '16506', '1', '2024-12-18', '77', '0','1650601','380','380','380','300','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16506', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16506', '1', '0', '0', '16506', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','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 ('R3354','','1','300','380', '380','380', '2024-12-18', '0', '77', '1', 'R3354', '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 (16507, 1,'2024-12-18 20:43:26',77)
                ON DUPLICATE KEY UPDATE productid = 16507, edited = 1, sysdate = '2024-12-18 20:43:26', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16507', '1', '2024-12-18', '77', '0','1650701','380','380','380','300','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16507', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16507', '1', '0', '0', '16507', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:13:44";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:43:44", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:43:44', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06763149b91a94
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(547,@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-18 20:29:47', '06763149b91a94', '547', '0.00', '500', '0', '1', '500.00', '500', '0', '500', '1', '2024-12-18 20:43:44', '', '104', '0', 'اسماء صلاح', '1', '1', '3', '4', 'اسماء صلاح', '1' ,'0','','','','','-1','0','0','0','0','0','500','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','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 = '500', userid = '104' WHERE clientid = '547';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('547','0.00','500','0','اضافة فاتورة مبيعات','150136', '500', '2024-12-18 20:43:44', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '500', '0', null, '0', null, null,'', '0','1','1','500','1','2024-12-18 20:29:47','0','0');
UPDATE client SET  inUse = 0 where clientid = 547;
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', '150136', '14', '16471', '1', '500', '500', '0', '', '1', '2024-12-18 20:43:44', '16471', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36461-1,','1','1','0','0','500','500','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 = 548521;
 INSERT INTO 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-18', 500, 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+500, 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-18', 500, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, 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 = '25', userid = '104', storedetaildate = '2024-12-18 20:43:44' WHERE storedetailid = '16470';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16471', '1', '1', '1', '150136', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '104', '2024-12-18 20:43:44','0','0');
UPDATE client SET  delegateid = 4 where clientid = 547;
 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-18', 500, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, 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 (547, '2024-12-18', 500, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, 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, 500, 410, 410
                    , 410, 410, 410, 410, 410, 410)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+500, 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 06763149b91a94 and sellbillId = 150136 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:13:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:43:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:43:45', '104', 'addsellBill', '192.168.1.13', '', '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 ('R3356','','1','325','400', '400','400', '2024-12-18', '0', '77', '1', 'R3356', '0', '0', '0', '0', '0', '325','325','325','325','325','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','325','325','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16508, 1,'2024-12-18 20:44:03',77)
                ON DUPLICATE KEY UPDATE productid = 16508, edited = 1, sysdate = '2024-12-18 20:44:03', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16508', '1', '2024-12-18', '77', '0','1650801','400','400','400','325','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16508', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16508', '1', '0', '0', '16508', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:14:16";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:44:16", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:44:16', '77', 'add', '192.168.1.21', '', '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 ('06763177c4f020', '2024-12-18 20:42:04', '47', '-9575.00', '8675', '0', '0', '18250',  '18250', '0', '18250', '1', '2024-12-18 20:44:16', '', '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 ('R3352', '14160', '1', '16506', '30', '300', '9000', '0', '', '2024-12-18 20:44:16', '16506','','','0','0','0','0','0',null,'300','9000','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-18 20:42:04', 1, 16506, 0, 0
                    , 300, 30, 0, 0, 77, '2024-12-18 20:44:16')
                ON DUPLICATE KEY UPDATE buyprice = 300,
                        buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 20:44:16' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16506', '300', '30', '0', 'buyBillController.php', '32767', '', '0', '0');
UPDATE product SET  productBuyPrice = "300" WHERE productId = 16506 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32767 ;
UPDATE product SET productName = 'R3352', productDescription = '', productCatId = '1', productBuyPrice = '300.00', productSellAllPrice = '380.00', productSellUnitPrice = '380.00', productSellHalfPrice = '380.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3352',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 = '16506';
UPDATE buybilldetail SET  lastbuyprice = 300 , meanbuyprice = 300, lastbuyprice_withDiscount = 300, meanbuyprice_withDiscount = 300
        , lastbuyprice_withTax = 300, meanbuyprice_withTax = 300, lastbuyprice_withDiscountAndTax = 300
                where buybilldetailid = 32767;
UPDATE productunit SET proUnitBuyPrice  = 300 * productnumber WHERE productid = 16506;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16505';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16506', '1', '30', '0', '14160', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '30', '77', '2024-12-18 20:42:04','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 ('R3354', '14160', '1', '16507', '20', '300', '6000', '0', '', '2024-12-18 20:44:16', '16507','','','0','0','0','0','0',null,'300','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-18 20:42:04', 1, 16507, 0, 0
                    , 300, 20, 0, 0, 77, '2024-12-18 20:44:16')
                ON DUPLICATE KEY UPDATE buyprice = 300,
                        buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 20:44:16' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16507', '300', '20', '0', 'buyBillController.php', '32768', '', '0', '0');
UPDATE product SET  productBuyPrice = "300" WHERE productId = 16507 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32768 ;
UPDATE product SET productName = 'R3354', productDescription = '', productCatId = '1', productBuyPrice = '300.00', productSellAllPrice = '380.00', productSellUnitPrice = '380.00', productSellHalfPrice = '380.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3354',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 = '16507';
UPDATE buybilldetail SET  lastbuyprice = 300 , meanbuyprice = 300, lastbuyprice_withDiscount = 300, meanbuyprice_withDiscount = 300
        , lastbuyprice_withTax = 300, meanbuyprice_withTax = 300, lastbuyprice_withDiscountAndTax = 300
                where buybilldetailid = 32768;
UPDATE productunit SET proUnitBuyPrice  = 300 * productnumber WHERE productid = 16507;
UPDATE storedetail SET  productquantity = '20', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16506';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16507', '1', '20', '0', '14160', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '20', '77', '2024-12-18 20:42:04','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 ('R3356', '14160', '1', '16508', '10', '325', '3250', '0', '', '2024-12-18 20:44:16', '16508','','','0','0','0','0','0',null,'325','3250','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-18 20:42:04', 1, 16508, 0, 0
                    , 325, 10, 0, 0, 77, '2024-12-18 20:44:16')
                ON DUPLICATE KEY UPDATE buyprice = 325,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 20:44:16' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16508', '325', '10', '0', 'buyBillController.php', '32769', '', '0', '0');
UPDATE product SET  productBuyPrice = "325" WHERE productId = 16508 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32769 ;
UPDATE product SET productName = 'R3356', productDescription = '', productCatId = '1', productBuyPrice = '325.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '400.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3356',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='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='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 = '16508';
UPDATE buybilldetail SET  lastbuyprice = 325 , meanbuyprice = 325, lastbuyprice_withDiscount = 325, meanbuyprice_withDiscount = 325
        , lastbuyprice_withTax = 325, meanbuyprice_withTax = 325, lastbuyprice_withDiscountAndTax = 325
                where buybilldetailid = 32769;
UPDATE productunit SET proUnitBuyPrice  = 325 * productnumber WHERE productid = 16508;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16507';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16508', '1', '10', '0', '14160', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-18 20:42:04','0','0');
UPDATE supplier SET  suppliercurrentDebt = '8675',suppliercurrentDebtInCurrency= '8675' , userid = '77', supplierdate = '2024-12-18 20:44:16'   WHERE supplierid = '47';
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 ('47', '-9575.00', '18250', '0', 'اضافة فاتورة مشتريات', '14160', '8675', '2024-12-18 20:42:04', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','18250','1','-9575','18250','8675','0');
update buybill set dailyentryid='0,' where buybillid=14160;
COMMIT;
UPDATE product SET overAllAveragePrice = 300 WHERE productId = 16506;UPDATE product SET overAllAveragePrice = 300 WHERE productId = 16507;UPDATE product SET overAllAveragePrice = 325 WHERE productId = 16508;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:14:16";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:44:16", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:44:16', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14160');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:14:22";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:44:22", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 20:44:22', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14160&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:18:50";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:48:50", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 20:48:50', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:18:53";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:48:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 20:48:53', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:19:14";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:49:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 20:49:14', '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-18', '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 = '262401.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('262614.50','213', '1', '2', 'إضافة مصروف', '25837', '262401.5', '2024-12-18 20:49:14', '2',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'نسبة تحويل و سحب', expensesdetails = '', expensesValue = '213.00', expensesdate = '2024-12-18', 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 = '25837';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:19:14";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:49:14", deviceType = "DESKTOP" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:19:14";
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 20:49:14', '2', 'sucess', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:49:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:49:14', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0676313380e92e
-- ----------------------------------------------------------------------------------------------------

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-18 20:23:52', '0676313380e92e', '1', '0.00', '0', '0', '1', '480.00', '480', '480', '0', '1', '2024-12-18 20:49:14', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150137', '0', '2024-12-18 20:49:14', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '480', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 20:23:52','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', '150137', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-18 20:49:15', '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 = 548522;
 INSERT INTO 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-18', 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-18', 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 = '66', userid = '104', storedetaildate = '2024-12-18 20:49:15' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '150137', 'اضافة فاتورة مبيعات', 'sellbillController.php', '67', '66', '104', '2024-12-18 20:49:15','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '7540',  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 ('7060','480', '0', '1', 'اضافة فاتورة مبيعات', '150137', '7540', '2024-12-18 20:49:15', '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-18', 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;
 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-18', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 480, 420, 420
                    , 420, 420, 420, 420, 420, 420)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+480, 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 0676313380e92e and sellbillId = 150137 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:19:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:49:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:49:15', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:19:16";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:49:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 20:49:16', '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-18 17:19:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:49:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:49:20', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:19:38";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:49:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 20:49:38', '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-18', '2', '0', '0','','1','1','0','0','96000');
UPDATE save SET  savecurrentvalue = '166401.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('262401.50','96000', '1', '2', 'تحويل امول الى الخزنة  [ دفعات اسبوعيه ] ', '3528', '166401.5', '2024-12-18 20:49:38', '2',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '336000',  userid = '2' WHERE saveid = '16';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('240000.00','96000', '0', '16', 'تحويل امول من الخزنة  [ فودافون كاش ] ', '3528', '336000', '2024-12-18 20:49:38', '2',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '2', saveidto = '16', transfermoneyvalue = '96000.00', transfermoneydate = '2024-12-18', userid = '2', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='96000' WHERE transfermoneyid = '3528';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:19:38";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:49:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 20:49:38', '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-18 17:19:40";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:49:40", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 20:49:40', '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-18 17:19:48";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:49:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 20:49:48', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:19:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:49:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:49:54', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 067631930c3171
-- ----------------------------------------------------------------------------------------------------

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-18 20:49:20', '067631930c3171', '1', '0.00', '0', '0', '1', '280.00', '280', '280', '0', '1', '2024-12-18 20:49:54', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '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-18','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','اضافة فاتورة مبيعات','150138', '0', '2024-12-18 20:49:54', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '280', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-18 20:49:20','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', '150138', '5', '16337', '1', '280', '280', '0', '', '1', '2024-12-18 20:49: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 = 548523;
 INSERT INTO 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-18', 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-18', 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 = '35', userid = '104', storedetaildate = '2024-12-18 20:49: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', '150138', 'اضافة فاتورة مبيعات', 'sellbillController.php', '36', '35', '104', '2024-12-18 20:49:54','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '7820',  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 ('7540','280', '0', '1', 'اضافة فاتورة مبيعات', '150138', '7820', '2024-12-18 20:49:54', '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-18', 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-18', 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 067631930c3171 and sellbillId = 150138 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:19:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:49:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:49:55', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:20:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:50:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 20:50:33', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:20:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:50:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 20:50:48', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=add');
BEGIN;
CALL supplierInUse(14,@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 ('14', '28445.00', '480', '1', 'ايصال دفع لمورد', '1', '27965', '2024-12-18 20:50:34', '104', 'supplierPayedDeptController.php', '', '0','1', '-1','1','1','480','1','0','0','0','407');
UPDATE supplierdebtchange SET supplierid = '14', supplierdebtchangebefore = '28445.00', supplierdebtchangeamount = '480', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '27965', supplierdebtchangedate = '2024-12-18 20:50:34', userid = '104', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='480',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='28445',debtchangamountInSupplierCurrency='27965',debtchangafterInSupplierCurrency='27965', paySerialNo='407' WHERE supplierdebtchangeid = '26826';
UPDATE supplier SET  suppliercurrentDebt = '27965',suppliercurrentDebtInCurrency= '27965' , userid = '104', supplierdate = '2024-12-18 20:50:48'   WHERE supplierid = '14';
UPDATE supplier SET  inUse = 0 where supplierid = 14;
UPDATE save SET  savecurrentvalue = '7340',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7820.00','480', '1', '1', 'ايصال دفع لمورد', '26826', '7340', '2024-12-18 20:50:48', '104',  'supplierPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '480', '480', '2024-12-18', '104', '0', '0', '2024-12-18 20:50:48','ايصال دفع لمورد ( روتانا مخزن عبد المنعيم  ) ','1','0','-1','0','26826','supplierReportsController.php?do=show&id=26826');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122201', '-1', '480', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '480', 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 ('122201', '-1', '480', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-480', 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 = '14', supplierdebtchangebefore = '28445.00', supplierdebtchangeamount = '480.00', supplierdebtchangetype = '1', processname = 'ايصال دفع لمورد', supplierdebtchangemodelid = '1', supplierdebtchangeafter = '27965.00', supplierdebtchangedate = '2024-12-18 20:50:34', userid = '104', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '122201',saveid = '1',currencyId='1',conversionFactor='1',payedInCurrency='480',saveConversionFactor='1',debtchangbeforeInSupplierCurrency='28445',debtchangamountInSupplierCurrency='27965',debtchangafterInSupplierCurrency='27965', paySerialNo='407' WHERE supplierdebtchangeid = '26826';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:20:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:50:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 20:50:49', '104', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:20:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:50:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-18 20:50:50', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:20:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:50:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-18 20:50:51', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:20:53";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:50:53", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 20:50:53', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14160&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:20:55";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:50:55", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:50:55', '77', 'show', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:21:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 20:51:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 20:51:01', '104', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:21:02";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:51:02", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:51:02', '77', 'editbill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editbill&id=14157');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:21:13";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:51:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 20:51:13', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:21:17";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:51:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 20:51:17', '2', 'show', '192.168.1.60', '', '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 ('H1693','','14','400','500', '500','500', '2024-12-18', '0', '77', '1', 'H1693', '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 (16509, 1,'2024-12-18 20:51:23',77)
                ON DUPLICATE KEY UPDATE productid = 16509, edited = 1, sysdate = '2024-12-18 20:51: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', '16509', '1', '2024-12-18', '77', '0','1650901','500','500','500','400','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16509', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16509', '1', '0', '0', '16509', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:21:29";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:51:29", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:51:29', '77', 'update', '192.168.1.21', '', '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 = 14157;
UPDATE buybill SET  buybillsysdate = '2024-12-18 20:51:29', userid = '77',delbyuserid = '77', conditions = '1' WHERE buybillid = '14157';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-18 20:31:40', 1, 16504, 0, 0
                    , 400, 10, 0, 0, 77, '2024-12-18 20:51:29')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-10, sellQuantity = sellQuantity-0,
                        del = 0,userid = 77,sysDate = '2024-12-18 20:51:29' ;
UPDATE buybilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400.00, meanbuyprice_withTax = 400.00, lastbuyprice_withDiscountAndTax = 400.00
                where buybilldetailid = 32763;
UPDATE product SET productName = 'H1692', productDescription = '', productCatId = '14', productBuyPrice = '400.00', productSellAllPrice = '550.00', productSellUnitPrice = '550.00', productSellHalfPrice = '550.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1692',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '400',lastbuyprice_withDiscount = '0',meanbuyprice = '400.00',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='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 = '16504';
UPDATE productunit SET proUnitBuyPrice  = 400 * productnumber WHERE productid = 16504;
UPDATE storedetail SET  productquantity = '0', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16503';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16504', '1', '10', '1', '14157', 'حذف فاتورة مشتريات - للتعديل', 'buyBillController.php', '10', '0', '77', '2024-12-18 20:31:40','0','0');
UPDATE supplier SET  suppliercurrentDebt = '316230',suppliercurrentDebtInCurrency= '316230' , userid = '77', supplierdate = '2024-12-18 20:51:29'   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', '4000.00', '1', 'حذف فاتورة مشتريات - للتعديل', '14157', '316230', '2024-12-18 20:31:40', '77', 'buyBillController.php', 'حذف فاتورة مشتريات - للتعديل', '0','', '0','1','1','4000','1','320230','4000','316230','0');
UPDATE productserial SET del = 1
		 WHERE billid = 14157;
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 ('06763150c219a1', '2024-12-18 20:32:19', '6', '316230.00', '320230', '0', '0', '4000', '4000', '0.00', '4000', '1', '2024-12-18 20:51:29', '', '77', '0', '', '1', '1','1','14157','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 ('H1692', '14161', '14', '16504', '5', '400', '2000', '0.00', '', '2024-12-18 20:51:29', '16504','','','0','0','0','0','0',null,'400','2000','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-18 20:32:19', 1, 16504, 0, 0
                    , 400, 5, 0, 0, 77, '2024-12-18 20:51:29')
                ON DUPLICATE KEY UPDATE buyprice = 400,
                        buyQuantity =buyQuantity+5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 20:51:29' ;
UPDATE product SET  productBuyPrice = "400" WHERE productId = 16504 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32770 ;
UPDATE product SET productName = 'H1692', productDescription = '', productCatId = '14', productBuyPrice = '400.00', productSellAllPrice = '550.00', productSellUnitPrice = '550.00', productSellHalfPrice = '550.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1692',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='133',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 = '16504';
UPDATE buybilldetail SET  lastbuyprice = 400 , meanbuyprice = 400, lastbuyprice_withDiscount = 400, meanbuyprice_withDiscount = 400
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 133, lastbuyprice_withDiscountAndTax = 400
                where buybilldetailid = 32770;
UPDATE productunit SET proUnitBuyPrice  = 400 * productnumber WHERE productid = 16504;
UPDATE storedetail SET  productquantity = '5', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16503';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16504', '1', '5', '0', '14161', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '5', '77', '2024-12-18 20:32:19','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 ('H1693', '14161', '14', '16509', '5', '400', '2000', '0', '', '2024-12-18 20:51:29', '16509','','','0','0','0','0','0',null,'400','2000','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-18 20:32:19', 1, 16509, 0, 0
                    , 400, 5, 0, 0, 77, '2024-12-18 20:51:29')
                ON DUPLICATE KEY UPDATE buyprice = 400,
                        buyQuantity =buyQuantity+5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 20:51:29' ;
UPDATE product SET  productBuyPrice = "400" WHERE productId = 16509 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32771 ;
UPDATE product SET productName = 'H1693', productDescription = '', productCatId = '14', productBuyPrice = '400.00', productSellAllPrice = '500.00', productSellUnitPrice = '500.00', productSellHalfPrice = '500.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1693',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 = '16509';
UPDATE buybilldetail SET  lastbuyprice = 400 , meanbuyprice = 400, lastbuyprice_withDiscount = 400, meanbuyprice_withDiscount = 400
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where buybilldetailid = 32771;
UPDATE productunit SET proUnitBuyPrice  = 400 * productnumber WHERE productid = 16509;
UPDATE storedetail SET  productquantity = '5', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16508';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16509', '1', '5', '0', '14161', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '5', '77', '2024-12-18 20:32:19','0','0');
DELETE FROM productserial WHERE billid = 14157
		and type =0 
		;
UPDATE supplier SET  suppliercurrentDebt = '320230',suppliercurrentDebtInCurrency= '320230' , userid = '77', supplierdate = '2024-12-18 20:51:29'   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', '316230.00', '4000', '0', 'اضافة فاتورة مشتريات', '14161', '320230', '2024-12-18 20:51:29', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','4000','1','316230','4000','320230','0');
update buybill set dailyentryid='0,' where buybillid=14161;
UPDATE product SET overAllAveragePrice = 400 WHERE productId = 16504;UPDATE product SET overAllAveragePrice = 400 WHERE productId = 16509;;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:21:30";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:51:30", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:51:30', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14161');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:21:35";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:51:35", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 20:51:35', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14161&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:22:35";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:52:35", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 20:52:35', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14161&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:22:37";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:52:37", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:52:37', '77', 'bill', '192.168.1.21', '', '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 ('7346','','5','430','520', '520','520', '2024-12-18', '0', '77', '1', '07346', '0', '0', '0', '0', '0', '430','430','430','430','430','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','430','430','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16510, 1,'2024-12-18 20:53:07',77)
                ON DUPLICATE KEY UPDATE productid = 16510, edited = 1, sysdate = '2024-12-18 20:53: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', '16510', '1', '2024-12-18', '77', '0','1651001','520','520','520','430','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16510', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16510', '1', '0', '0', '16510', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','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 ('H1691','','14','575','700', '700','700', '2024-12-18', '0', '77', '1', 'H1691', '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 (16511, 1,'2024-12-18 20:53:31',77)
                ON DUPLICATE KEY UPDATE productid = 16511, edited = 1, sysdate = '2024-12-18 20:53: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', '16511', '1', '2024-12-18', '77', '0','1651101','700','700','700','575','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16511', '1', '0', '77', '2024-12-18');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16511', '1', '0', '0', '16511', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-18','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:23:56";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:53:56", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:53:56', '77', 'add', '192.168.1.21', '', '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 ('0676319f55beab', '2024-12-18 20:52:37', '20', '329635.00', '361460', '0', '0', '31825',  '31825', '0', '31825', '1', '2024-12-18 20:53: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 ('07221', '14162', '5', '16279', '50', '335', '16750', '0', '', '2024-12-18 20:53:56', '16279','','','0','0','0','0','0',null,'335','16750','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-18 20:52:37', 1, 16279, 0, 0
                    , 335, 50, 0, 0, 77, '2024-12-18 20:53:56')
                ON DUPLICATE KEY UPDATE buyprice = 335,
                        buyQuantity =buyQuantity+50, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 20:53:56' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16279', '335', '50', '0', 'buyBillController.php', '32772', '', '0', '0');
UPDATE product SET  productBuyPrice = "335" WHERE productId = 16279 ;
UPDATE buybilldetail SET  quantitybefore = 33 WHERE buybilldetailid = 32772 ;
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='323',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 = 323, lastbuyprice_withDiscountAndTax = 335
                where buybilldetailid = 32772;
UPDATE productunit SET proUnitBuyPrice  = 335 * productnumber WHERE productid = 16279;
UPDATE storedetail SET  productquantity = '83', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '50', '0', '14162', 'اضافة فاتورة مشتريات', 'buyBillController.php', '33', '83', '77', '2024-12-18 20:52:37','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 ('07346', '14162', '5', '16510', '15', '430', '6450', '0', '', '2024-12-18 20:53:56', '16510','','','0','0','0','0','0',null,'430','6450','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-18 20:52:37', 1, 16510, 0, 0
                    , 430, 15, 0, 0, 77, '2024-12-18 20:53:57')
                ON DUPLICATE KEY UPDATE buyprice = 430,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 20:53:57' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16510', '430', '15', '0', 'buyBillController.php', '32773', '', '0', '0');
UPDATE product SET  productBuyPrice = "430" WHERE productId = 16510 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32773 ;
UPDATE product SET productName = '7346', productDescription = '', productCatId = '5', productBuyPrice = '430.00', productSellAllPrice = '520.00', productSellUnitPrice = '520.00', productSellHalfPrice = '520.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07346',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '430',lastbuyprice_withDiscount = '430',meanbuyprice = '430',meanbuyprice_withDiscount = '430' , productbuypricereal = '430.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='430',meanbuyprice_withTax='430',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='430'  WHERE productId = '16510';
UPDATE buybilldetail SET  lastbuyprice = 430 , meanbuyprice = 430, lastbuyprice_withDiscount = 430, meanbuyprice_withDiscount = 430
        , lastbuyprice_withTax = 430, meanbuyprice_withTax = 430, lastbuyprice_withDiscountAndTax = 430
                where buybilldetailid = 32773;
UPDATE productunit SET proUnitBuyPrice  = 430 * productnumber WHERE productid = 16510;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16509';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16510', '1', '15', '0', '14162', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 20:52:37','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 ('H1691', '14162', '14', '16511', '15', '575', '8625', '0', '', '2024-12-18 20:53:56', '16511','','','0','0','0','0','0',null,'575','8625','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-18 20:52:37', 1, 16511, 0, 0
                    , 575, 15, 0, 0, 77, '2024-12-18 20:53:57')
                ON DUPLICATE KEY UPDATE buyprice = 575,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-18 20:53:57' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16511', '575', '15', '0', 'buyBillController.php', '32774', '', '0', '0');
UPDATE product SET  productBuyPrice = "575" WHERE productId = 16511 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32774 ;
UPDATE product SET productName = 'H1691', productDescription = '', productCatId = '14', productBuyPrice = '575.00', productSellAllPrice = '700.00', productSellUnitPrice = '700.00', productSellHalfPrice = '700.00', productDate = '2024-12-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1691',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 = '16511';
UPDATE buybilldetail SET  lastbuyprice = 575 , meanbuyprice = 575, lastbuyprice_withDiscount = 575, meanbuyprice_withDiscount = 575
        , lastbuyprice_withTax = 575, meanbuyprice_withTax = 575, lastbuyprice_withDiscountAndTax = 575
                where buybilldetailid = 32774;
UPDATE productunit SET proUnitBuyPrice  = 575 * productnumber WHERE productid = 16511;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-18' WHERE storedetailid = '16510';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16511', '1', '15', '0', '14162', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-18 20:52:37','0','0');
UPDATE supplier SET  suppliercurrentDebt = '361460',suppliercurrentDebtInCurrency= '361460' , userid = '77', supplierdate = '2024-12-18 20:53:56'   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', '329635.00', '31825', '0', 'اضافة فاتورة مشتريات', '14162', '361460', '2024-12-18 20:52:37', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','31825','1','329635','31825','361460','0');
update buybill set dailyentryid='0,' where buybillid=14162;
COMMIT;
UPDATE product SET overAllAveragePrice = 335 WHERE productId = 16279;UPDATE product SET overAllAveragePrice = 430 WHERE productId = 16510;UPDATE product SET overAllAveragePrice = 575 WHERE productId = 16511;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:23:57";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:53:57", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:53:57', '77', 'editprint', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14162');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:24:00";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:54:00", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 20:54:00', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14162&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:24:30";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:54:30", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 20:54:30', '77', 'showbarcodebuybill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14162&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:24:32";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:54:32", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-18 20:54:32', '77', 'bill', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:25:19";
UPDATE user SET loginip = "192.168.1.21", lastactivetime = "2024-12-18 20:55:19", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-18 20:55:19', '77', 'showbarcode', '192.168.1.21', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:29:44";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:59:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 20:59:44', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:29:46";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:59:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 20:59:46', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:29:55";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 20:59:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 20:59:55', '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-18 17:35:34";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:05:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-18 21:05:34', '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-18 17:37:28";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:07:28", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-18 21:07:28', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:38:40";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:08:40", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-18 21:08:40', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:38:58";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:08:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-18 21:08:58', '2', 'add', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =10312
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10312,@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 ('10312','-680.00','680','0','تسوية عجز عميل بالزيادة','-1', '0', '2024-12-18 21:08:58', '2', 'clientDeficitController.php', '', '680', '0', null, '0', null, null,'', '0','1','1','680','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18', userid = '2' WHERE clientid = '10312';
UPDATE client SET  inUse = 0 where clientid = 10312;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '680', '680', '2024-12-18', '2', '0', '0', '2024-12-18 21:08:58','تم اضافة معالجة عجز للعميل دينا محمد 77(تسوية بالاضافة)','1','0','0','0','0','');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122202', '11358', '680', '','0');
UPDATE accountstree SET name = 'دينا محمد 77', customName = 'دينا محمد 77', customNameEn = 'دينا محمد 77', nameEn = 'دينا محمد 77', parent = '58', accountNature = '0', theValue = '-997', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-11-08 12:31:28' WHERE id = '11358';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122202', '146', '680', '','0');
UPDATE accountstree SET name = 'مريم زكريا S29', customName = 'مريم زكريا S29', customNameEn = '', nameEn = '', parent = '23', accountNature = '0', theValue = '-32935', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '0000-00-00 00:00:00' WHERE id = '146';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =10312 ,id=247507
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:38:58";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:08:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-18 21:08:58', '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-18 17:39:00";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:09:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-18 21:09:00', '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-18 17:40:13";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:10:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-18 21:10:13', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:40:27";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:10:27", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-18 21:10:27', '2', 'add', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =2224
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2224,@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 ('2224','-93.00','93','0','تسوية عجز عميل بالزيادة','-1', '0', '2024-12-18 21:10:27', '2', 'clientDeficitController.php', '', '93', '0', null, '0', null, null,'', '0','1','1','93','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-18', userid = '2' WHERE clientid = '2224';
UPDATE client SET  inUse = 0 where clientid = 2224;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =2224 ,id=247508
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:40:28";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:10:28", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-18 21:10:28', '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-18 17:40:29";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:10:29", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-18 21:10:29', '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-18 17:40:41";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:10:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-18 21:10:41', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 17:45:21";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:15:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 21:15:21', '2', 'addsellBill', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 18:06:54";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:36:54", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 21:36:54', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 18:07:03";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:37:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-18 21:37:03', '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-18 18:07:10";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:37:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 21:37:10', '2', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=130662');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 18:09:41";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:39:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 21:39:41', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 18:09:49";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:39:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 21:39:49', '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', 'باقي حساب عميل', '', '799', '2024-12-18', '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 = '165602.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('166401.50','799', '1', '2', 'إضافة مصروف', '25838', '165602.5', '2024-12-18 21:39:49', '2',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'باقي حساب عميل', expensesdetails = '', expensesValue = '799.00', expensesdate = '2024-12-18', 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 = '25838';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 18:09:49";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:39:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 21:39:49', '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-18 18:09:51";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:39:51", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 21:39:51', '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-18 18:09:53";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-18 21:39:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 21:39:53', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 19:08: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-18 19:08:28";
UPDATE user SET loginip = "156.182.216.241", lastactivetime = "2024-12-18 22:38:28", deviceType = "MOBILE" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 22:38:28', '104', '', '156.182.216.241', '', 'MOBILE','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-18 19:08:28";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 19:08:40";
UPDATE user SET loginip = "156.182.216.241", lastactivetime = "2024-12-18 22:38:40", deviceType = "MOBILE" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 22:38:40', '104', '', '156.182.216.241', '', 'MOBILE','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 19:12:51";
UPDATE user SET loginip = "156.182.216.241", lastactivetime = "2024-12-18 22:42:51", deviceType = "MOBILE" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 22:42:51', '104', '', '156.182.216.241', '', 'MOBILE','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 19:13:51";
UPDATE user SET loginip = "156.182.216.241", lastactivetime = "2024-12-18 22:43:51", deviceType = "MOBILE" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 22:43:51', '104', '', '156.182.216.241', '', 'MOBILE','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-18 19:13:52";
update user set blockedByLimits = 0;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 19:13:53";
UPDATE user SET loginip = "156.182.216.241", lastactivetime = "2024-12-18 22:43:53", deviceType = "MOBILE" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 22:43:53', '104', '', '156.182.216.241', '', 'MOBILE','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-18 19:13:53";
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-18 19:21:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 22:51:39", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 22:51:39', '9', '', '192.168.1.13', '', '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-18 19:21:39";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 19:21:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 22:51:41", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 22:51:41', '9', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 19:21:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 22:51:45", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 22:51:45', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 19:22:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 22:52:54", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnsellbillController.php', '2024-12-18 22:52:54', '9', 'showDetail', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnsellbillController.php?do=showDetail&returnsellbillid=16822');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 19:23:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 22:53:29", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 22:53:29', '9', 'showDetail', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=150126');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:00:53";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:30:53", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:30:53', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:01:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:31:05", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:31:05', '9', 'add', '192.168.1.13', '', '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-18', '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 = '7240',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7340.00','100', '1', '1', 'إضافة مصروف', '25839', '7240', '2024-12-18 23:31:05', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كريم هادي', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-18', 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 = '25839';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:01:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:31:06", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:31:06', '9', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:01:08";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:31:08", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:31:08', '9', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:01:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:31:11", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:31:11', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:01:23";
UPDATE user SET loginip = "156.182.216.241", lastactivetime = "2024-12-18 23:31:23", deviceType = "MOBILE" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-18 23:31:23', '104', '', '156.182.216.241', '', 'MOBILE','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-18 20:01:24";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:02:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:32:05", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:32:05', '9', 'add', '192.168.1.13', '', '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-18', '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 = '7140',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7240.00','100', '1', '1', 'إضافة مصروف', '25840', '7140', '2024-12-18 23:32:05', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'عبده صاله', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-18', 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 = '25840';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:02:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:32:05", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:32:05', '9', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:02:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:32:07", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:32:07', '9', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:02:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:32:09", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 23:32:09', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:03:00";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:33:00", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 23:33:00', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:03:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:33:15", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:33:15', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:03:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:33:23", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:33:23', '9', 'add', '192.168.1.13', '', '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-18', '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 = '7040',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7140.00','100', '1', '1', 'إضافة مصروف', '25841', '7040', '2024-12-18 23:33:23', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'محمد عبدة', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-18', 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 = '25841';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:03:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:33:24", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:33:24', '9', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:03:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:33:25", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:33:25', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:03:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:33:38", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:33:38', '9', 'add', '192.168.1.13', '', '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', 'ابراهيم الصغير ازاء', '', '70', '2024-12-18', '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 = '6970',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7040.00','70', '1', '1', 'إضافة مصروف', '25842', '6970', '2024-12-18 23:33:38', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'ابراهيم الصغير ازاء', expensesdetails = '', expensesValue = '70.00', expensesdate = '2024-12-18', 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 = '25842';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:03:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:33:38", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:33:38', '9', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:03:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:33:40", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 23:33:40', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:04:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:34:19", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 23:34:19', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:04:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:34:31", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 23:34:31', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:05:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:35:28", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:35:28', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:05:35";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:35:35", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:35:35', '9', 'add', '192.168.1.13', '', '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-18', '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 = '6870',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6970.00','100', '1', '1', 'إضافة مصروف', '25843', '6870', '2024-12-18 23:35:35', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'ابراهيم الصغير', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-18', 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 = '25843';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:05:35";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:35:35", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:35:35', '9', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:05:37";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:35:37", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:35:37', '9', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:05:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:35:41", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 23:35:41', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:05:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:35:51", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 23:35:51', '9', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:06:03";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:36:03", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 23:36:03', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:07:03";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:37:03", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:37:03', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:07:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:37:15", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:37:15', '9', 'add', '192.168.1.13', '', '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-18', '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 = '6820',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6870.00','50', '1', '1', 'إضافة مصروف', '25844', '6820', '2024-12-18 23:37:15', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'محمد عادل', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-18', 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 = '25844';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:07:16";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:37:16", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:37:16', '9', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:07:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:37:18", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:37:18', '9', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:07:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:37:25", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 23:37:25', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:07:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:37:51", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:37:51', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:07:58";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:37:58", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:37:58', '9', 'add', '192.168.1.13', '', '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-18', '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 = '6620',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6820.00','200', '1', '1', 'إضافة مصروف', '25845', '6620', '2024-12-18 23:37:58', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'رضوي', expensesdetails = '', expensesValue = '200.00', expensesdate = '2024-12-18', 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 = '25845';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:07:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:37:59", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:37:59', '9', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:08:00";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:38:00", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 23:38:00', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:08:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:38:39", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 23:38:39', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:08:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:38:54", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 23:38:54', '9', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =247509
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3677,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-8465' , clientdate = '2024-12-18 23:38:54', userid = '9' WHERE clientid = '3677';
UPDATE client SET  inUse = 0 where clientid = 3677;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3677','-8355.00','110','1','ايصال تحصيل (( قبض من عميل ))','247509', '-8465', '2024-12-18 23:38:39', '9', 'clientPayedDeptController.php', '   ', '110', '0', null, '0', null, null,'', '-1','1','1','110','1','','3551','0');
UPDATE save SET  savecurrentvalue = '6730',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6620.00','110', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '247509', '6730', '2024-12-18 23:38:54', '9',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '110', '110', '2024-12-18', '9', '0', '0', '2024-12-18 23:38:54','اضافة ايصال سداد للعميل زيادة ','1','0','0','0','247509','clientPayedDeptController.php?do=show&id=247509');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('122203', '-1', '110', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '110', 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 ('122203', '-1', '110', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-110', 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 = '3677', clientdebtchangebefore = '-8355.000', clientdebtchangeamount = '110.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '247509', clientdebtchangeafter = '-8465.000', clientdebtchangedate = '2024-12-18 23:38:39', userid = '9', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '110.00',discount='', reciptid='0', dailyentryid = '122203',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='110',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '247509';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:08:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:38:55", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 23:38:55', '9', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:08:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:38:57", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-18 23:38:57', '9', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:09:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:39:01", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:39:01', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:09:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:39:07", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:39:07', '9', 'add', '192.168.1.13', '', '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', 'كرت شحن', '', '30', '2024-12-18', '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 = '6700',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('6730.00','30', '1', '1', 'إضافة مصروف', '25846', '6700', '2024-12-18 23:39:07', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كرت شحن', expensesdetails = '', expensesValue = '30.00', expensesdate = '2024-12-18', 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 = '25846';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:09:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:39:07", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:39:07', '9', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:09:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:39:09", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-18 23:39:09', '9', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:12:27";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:42:27", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 23:42:27', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:12:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:42:34", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 23:42:34', '9', 'add', '192.168.1.13', '', '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', '6700', '2024-12-18', '9', '0', '0','','1','1','0','0','6700');
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 ('6700.00','6700', '1', '1', 'تحويل امول الى الخزنة  [ خزنة البيت ] ', '3529', '0', '2024-12-18 23:42:34', '9',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '107665',  userid = '9' WHERE saveid = '4';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('100965.00','6700', '0', '4', 'تحويل امول من الخزنة  [ نقدي ] ', '3529', '107665', '2024-12-18 23:42:34', '9',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '4', transfermoneyvalue = '6700.00', transfermoneydate = '2024-12-18', userid = '9', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='6700' WHERE transfermoneyid = '3529';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:12:35";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:42:35", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 23:42:35', '9', 'sucess', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:12:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:42:36", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 23:42:36', '9', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:13:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:43:01", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 23:43:01', '9', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:13:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:43:06", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 23:43:06', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:13:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:43:21", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-18 23:43:21', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:13:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:43:30", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-18 23:43:30', '9', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-18 20:14:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-18 23:44:25", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-18 23:44:25', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
