UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 05:15:35";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 08:45:35", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 08:45:35', '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-12 05:15:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 08:45:36", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 08:45:36', '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 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-11',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-12 05:17:37";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 08:47:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 08:47:37', '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-12',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-12 05:17:41";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 05:41:44";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 09:11:44", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 09:11: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-12 05:41:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 09:11:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 09:11:54', '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-12 05:43:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 09:13:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 09:13: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-12 05:43:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 09:13:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 09:13: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-12 06:37:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:07:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 10:07: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 0675a8d1619499
-- ----------------------------------------------------------------------------------------------------

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-12 09:13:26', '0675a8d1619499', '1', '0.00', '0', '0', '1', '360.00', '360', '360', '0', '1', '2024-12-12 10:07:46', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '2' ,'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-12','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','اضافة فاتورة مبيعات','149063', '0', '2024-12-12 10:07:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '360', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 09:13:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35960;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1598', '149063', '14', '16220', '1', '260', '260', '0', '', '1', '2024-12-12 10:07:46', '16220', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35960-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 = 544678;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16220, '2024-12-12', 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-12', 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 = '12', userid = '104', storedetaildate = '2024-12-12 10:07:46' WHERE storedetailid = '16219';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16220', '1', '1', '1', '149063', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '104', '2024-12-12 10: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 ('50','000M1', '149063', '1', '4724', '1', '100', '100', '0', '', '1', '2024-12-12 10:07:46', '4724', '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 = 50.00 , meanbuyprice = 50.00, lastbuyprice_withDiscount = 50.00, meanbuyprice_withDiscount = 50.00
        
                where sellbilldetailid = 544679;
 INSERT INTO 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-12', 100, 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+100, 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-12', 100, 50, 50
                    , 50, 50, 50, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, 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 = '-134', userid = '104', storedetaildate = '2024-12-12 10:07:46' WHERE storedetailid = '4723';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('4724', '1', '1', '1', '149063', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-133', '-134', '104', '2024-12-12 10:07:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '360',  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','360', '0', '1', 'اضافة فاتورة مبيعات', '149063', '360', '2024-12-12 10:07:46', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 360, 250, 250
                    , 250, 250, 250, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , 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-12', 360, 250, 250
                    , 250, 250, 250, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , 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, 360, 250, 250
                    , 250, 250, 250, 200, 200, 200)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+360, netSellCostBuyPrice = netSellCostBuyPrice+250
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+250
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+250
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+250
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+250
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+200
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+200
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+200;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675a8d1619499 and sellbillId = 149063 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 06:37:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:07:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 10:07: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-12 06:45:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:15:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 10:15:02', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 06:45:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:15:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 10:15:10', '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-12 06:47:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:17:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 10:17: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-12 06:47:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:17:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 10:17:28', '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-12 06:48:04";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:18:04", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 10:18:04', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675a9c1923937
-- ----------------------------------------------------------------------------------------------------

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-12 10:17:29', '0675a9c1923937', '1', '0.00', '0', '0', '1', '-145.00', '-145', '-145', '0', '1', '2024-12-12 10:18:04', '', '104', '0', 'نقدي', '1', '0', '4', '0', '185', '330', 'نقدي', '1', '1', '0', '', '', '','','-1','0','0','0','','0','-145','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','اضافة فاتورة مبيعات ومردودات','84', '0', '2024-12-12 10:18:04', '104', 'sellbillandruternController.php', 'اضافة فاتورة مبيعات ومردودات', '145', '0', null, '0', null, null,'', '0','1','1','-0','1','2024-12-12 10:17:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36041;
INSERT INTO sellandruternbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, selltype, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,buyPricesHistoryBookIdQuantity,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,categorydiscount,lastbuyprice_withDiscountAndTax) VALUES ('145','07093', '84', '5', '16084', '1', '185', '185.00', '0', '', '0', '2024-12-12 10:18:04', '0', '16084', '0.00', '-1', '1','0','','','0','0','0','0','0','0','36041-1,','1','1','','0','0','185','185','0','','','0');
UPDATE sellandruternbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 218;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16084, '2024-12-12', 185, 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+185, 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-12', 185, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-12 10:18:04' WHERE storedetailid = '16083';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16084', '1', '1', '1', '84', 'فاتوره مبيعات ومردودات', 'sellbillandruternController.php', '4', '3', '104', '2024-12-12 10:18:04','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 ('275.00','07091', '84', '5', '16093', '1', '330', '330', '0', '', '0', '2024-12-12 10:18:04', '1', '16093', '0.00', '-1', '1','0','','','0','0','0','0','0','0','','1','1','','0','0','330','330','0','','','0');
UPDATE sellandruternbilldetail SET  lastbuyprice = 275.00 , meanbuyprice = 275.00, lastbuyprice_withDiscount = 275.00, meanbuyprice_withDiscount = 275.00
        , lastbuyprice_withTax = 275, meanbuyprice_withTax = 275, lastbuyprice_withDiscountAndTax = 275
                where sellbilldetailid = 219;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16093, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 330, 275, 275, 275
                    , 275, 275, 275, 0, 1, 0, 0, 275, 275)
                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+275, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+275
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+275, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+275
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+275
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+275
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+275
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+275
                        , 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 330, 275, 275, 275
                    , 275, 275, 275, 0, 0, 275, 275)
                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+275, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+275
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+275, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+275
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+275
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+275
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+275
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+275;
UPDATE storedetail SET  productquantity = '11', userid = '104', storedetaildate = '2024-12-12 10:18:04' WHERE storedetailid = '16092';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16093', '1', '1', '0', '84', 'اضافة فاتورة مردودات مبيعات', 'sellbillandruternController.php', '10', '11', '104', '2024-12-12 10:18:04','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '215',  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 ('360','145', '1', '1', 'اضافة فاتورة مبيعات ومردودات', '84', '215', '2024-12-12 10:18:04', '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-12', 185, 145, 145
                    , 145, 145, 145, 145
                    , 330, 275, 275, 275
                    , 275, 275, 275 ,145, 145, 275, 275)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, 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+330, returnSellCostBuyPrice = returnSellCostBuyPrice+275, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+275
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+275, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+275
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+275
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+275
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+275
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+275;
 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-12', 185, 145, 145
                    , 145, 145, 145, 145
                    , 330, 275, 275, 275
                    , 275, 275, 275 ,145, 145, 275, 275)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, 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+330, returnSellCostBuyPrice = returnSellCostBuyPrice+275, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+275
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+275, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+275
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+275
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+275
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+275
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+275;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -145, -130, -130
                    , -130, -130, -130, -130, -130, -130)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-145, netSellCostBuyPrice = netSellCostBuyPrice+-130
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-130
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-130
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-130
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-130
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-130
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-130
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-130;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675a9c1923937 and sellbillId = 84 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 06:48:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:18:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-12 10:18:05', '104', 'editprint', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=editprint&id=84');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 06:49:00";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:19:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 10:19:00', '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-12 06:52:00";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:22:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 10:22: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 0675a9c7497c9d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6292,@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-12 10:19:00', '0675a9c7497c9d', '6292', '0.00', '364', '0', '1', '364.00', '364', '0', '364', '1', '2024-12-12 10:22:00', '', '104', '0', 'منال صلاح 41', '1', '1', '3', '95', 'منال صلاح 41', '2' ,'0','','','','','-1','0','0','0','0','0','364','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '364', userid = '104' WHERE clientid = '6292';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6292','0.00','364','0','اضافة فاتورة مبيعات','149064', '364', '2024-12-12 10:22:00', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '364', '0', null, '0', null, null,'', '0','1','1','364','1','2024-12-12 10:19:00','0','0');
UPDATE client SET  inUse = 0 where clientid = 6292;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35789;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149064', '5', '15654', '1', '360', '360', '0', '', '1', '2024-12-12 10:22:00', '15654', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35789-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 = 544680;
 INSERT INTO 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-12', 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-12', 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 = '8', userid = '104', storedetaildate = '2024-12-12 10:22:00' WHERE storedetailid = '15653';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15654', '1', '1', '1', '149064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-12 10:22: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 ('0','10291', '149064', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-12 10:22:00', '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 = 95 where clientid = 6292;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 364, 295, 295
                    , 113, 295, 113, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 113, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+364, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6292, '2024-12-12', 364, 295, 295
                    , 113, 295, 113, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 113, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+364, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 364, 295, 295
                    , 113, 295, 113, 295, 295, 113)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+364, netSellCostBuyPrice = netSellCostBuyPrice+295
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+295
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+113
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+295
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+113
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+295
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+295
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+113;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675a9c7497c9d and sellbillId = 149064 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 06:52:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:22:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 10:22: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-12 07:04:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:34:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 10:34:20', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 07:04:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:34:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 10:34:31', '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-12', '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 = '165',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('215.00','50', '1', '1', 'إضافة مصروف', '25604', '165', '2024-12-12 10:34:31', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'حبيبه سيد التؤم', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25604';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 07:04:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:34:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 10:34:32', '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-12 07:04:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:34:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 10:34:33', '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-12 07:07:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:37:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 10:37:05', '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-12 07:10:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:40:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 10:40: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 0675aa0b141481
-- ----------------------------------------------------------------------------------------------------

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-12 10:37:05', '0675aa0b141481', '1', '0.00', '0', '0', '1', '200', '200', '-200', '0', '1', '2024-12-12 10:40:39', '', '104', '0', 'نقدي','1', '0', '5', '26', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-200','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16736', '0', '2024-12-12 10:40:39', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 10:37:05','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', '07150', '16736', '5', '16249', '1', '200', '200', '0', '', '1', '0', '16249', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','200','200','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 106.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 106.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 71, lastbuyprice_withDiscountAndTax = 140
                where returnsellbilldetailid = 21896;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16249, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 140, 140, 106
                    , 140, 106, 140, 0, 1, 0, 0, 140, 71)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+200, returnSellCostBuyPrice = returnSellCostBuyPrice+140, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+140
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+106, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+140
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+106
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+140
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+140
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+71
                        , 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 140, 140, 106
                    , 140, 106, 140, 0, 0, 140, 71)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+200, returnSellCostBuyPrice = returnSellCostBuyPrice+140, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+140
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+106, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+140
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+106
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+140
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+140
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+71;
UPDATE storedetail SET  productquantity = '6', userid = '104', storedetaildate = '2024-12-12 10:40:39' WHERE storedetailid = '16248';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16249', '1', '1', '0', '16736', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '5', '6', '104', '2024-12-12 10:40:39','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '-35',  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 ('165','-200', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16736', '-35', '2024-12-12 10:40:39', '104',  'returnsellbillController.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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 140, 140, 106
                    , 140, 106, 140 ,0, 0, 140, 71)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+200, returnSellCostBuyPrice = returnSellCostBuyPrice+140, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+140
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+106, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+140
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+106
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+140
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+140
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+71;
 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 140, 140, 106
                    , 140, 106, 140 ,0, 0, 140, 71)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+200, returnSellCostBuyPrice = returnSellCostBuyPrice+140, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+140
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+106, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+140
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+106
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+140
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+140
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+71;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -200, -140, -140
                    , -106, -140, -106, -140, -140, -71)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-200, netSellCostBuyPrice = netSellCostBuyPrice+-140
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-140
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-106
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-140
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-106
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-140
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-140
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-71;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aa0b141481 and sellbillId = 16736 and returnsellbillId = 16736
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245681
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675aa2aaee2ea
-- ----------------------------------------------------------------------------------------------------

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-12 10:45:30', '0675aa2aaee2ea', '1', '0.00', '0', '0', '1', '420.00', '420', '420', '0', '1', '2024-12-12 10:45:49', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','420','0','','0','0','420','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149065', '0', '2024-12-12 10:45:49', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '420', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 10:45:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35502;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06980', '149065', '5', '15944', '1', '420', '420', '0', '', '1', '2024-12-12 10:45:49', '15944', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35502-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 = 544682;
 INSERT INTO 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-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '19', userid = '104', storedetaildate = '2024-12-12 10:45:49' WHERE storedetailid = '15943';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15944', '1', '1', '1', '149065', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '104', '2024-12-12 10:45:49','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '585',  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 ('165','420', '0', '1', 'اضافة فاتورة مبيعات', '149065', '585', '2024-12-12 10:45:49', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 420, 360, 360
                    , 360, 360, 360, 360, 360, 360)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+420, netSellCostBuyPrice = netSellCostBuyPrice+360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+360
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+360
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+360
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+360
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+360
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+360
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+360;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aa2aaee2ea and sellbillId = 149065 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 07:15:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:45:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 10:45: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 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-12 07:16:34";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 10:46:34", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 10:46:34', '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-12 07:16:35";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 07:16:48";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 10:46:48", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 10:46: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-12 07:27:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 10:57:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 10:57: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 0675aa2be754f3
-- ----------------------------------------------------------------------------------------------------

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-12 10:45:50', '0675aa2be754f3', '1', '0.00', '0', '0', '1', '400.00', '400', '400', '0', '1', '2024-12-12 10:57:23', '', '104', '0', 'نقدي', '1', '0', '3', '94', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149066', '0', '2024-12-12 10:57:23', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '400', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 10:45: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 ('445','05916', '149066', '5', '13205', '1', '400', '400', '0', '', '1', '2024-12-12 10:57:23', '13205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','400','400','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 = 544683;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13205, '2024-12-12', 400, 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+400, 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-12', 400, 445, 445
                    , 445, 445, 445, 445
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, 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 = '-5', userid = '104', storedetaildate = '2024-12-12 10:57:23' WHERE storedetailid = '13204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13205', '1', '1', '1', '149066', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-4', '-5', '104', '2024-12-12 10:57:23','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '985',  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 ('585','400', '0', '1', 'اضافة فاتورة مبيعات', '149066', '985', '2024-12-12 10:57:23', '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-12', 400, 445, 445
                    , 445, 445, 445, 445
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, 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;
 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-12', 400, 445, 445
                    , 445, 445, 445, 445
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 400, 445, 445
                    , 445, 445, 445, 445, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+400, netSellCostBuyPrice = netSellCostBuyPrice+445
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+445
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+445
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+445
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+445
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+445
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aa2be754f3 and sellbillId = 149066 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675aa2f8bc8a7
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1257,@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-12 10:46:48', '0675aa2f8bc8a7', '1257', '0.00', '7958', '390', '1', '8348.00', '7958', '0', '7958', '1', '2024-12-12 10:58:29', '', '75', '0', 'ميرا المنصورة 52', '2', '1', '3', '90', 'ميرا المنصورة 52', '28' ,'0','','','','','-1','0','0','0','0','0','7958','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '7958', userid = '75' WHERE clientid = '1257';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1257','0.00','7958','0','اضافة فاتورة مبيعات','149067', '7958', '2024-12-12 10:58:29', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '7958', '0', null, '0', null, null,'', '0','1','1','7958','1','2024-12-12 10:46:48','0','0');
UPDATE client SET  inUse = 0 where clientid = 1257;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35718;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('260','06903', '149067', '5', '15753', '1', '320', '320', '0', '', '1', '2024-12-12 10:58:29', '15753', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35718-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 260.00
        , lastbuyprice_withTax = 260, meanbuyprice_withTax = 259, lastbuyprice_withDiscountAndTax = 260
                where sellbilldetailid = 544684;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15753, '2024-12-12', 305.05031145184, 260, 260
                    , 260, 260, 260, 259.29
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 260, 259, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+305.05031145184, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+259
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 305.05031145184, 260, 260
                    , 260, 260, 260, 259.29
                    , 0, 0, 0, 0
                    , 0, 0, 0, 260, 259, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+305.05031145184, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+259.29
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+259
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 10:58:29' WHERE storedetailid = '15752';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15753', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-8', '-9', '75', '2024-12-12 10:58:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35929;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','07200', '149067', '5', '16305', '1', '300', '300', '0', '', '1', '2024-12-12 10:58:29', '16305', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35929-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 544685;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16305, '2024-12-12', 285.9846669861, 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.9846669861, 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-12', 285.9846669861, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+285.9846669861, 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 = '12', userid = '75', storedetaildate = '2024-12-12 10:58:29' WHERE storedetailid = '16304';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16305', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-12 10:58:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35920;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149067', '14', '16298', '2', '250', '500', '0', '', '1', '2024-12-12 10:58:29', '16298', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35920-2,','1','1','0','0','250','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 185.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 185.00
        , lastbuyprice_withTax = 185, meanbuyprice_withTax = 185, lastbuyprice_withDiscountAndTax = 185
                where sellbilldetailid = 544686;
 INSERT INTO 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-12', 476.64111164351, 370, 370
                    , 370, 370, 370, 370
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 370, 370, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+476.64111164351, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+370
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+370
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+370
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 476.64111164351, 370, 370
                    , 370, 370, 370, 370
                    , 0, 0, 0, 0
                    , 0, 0, 0, 370, 370, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+476.64111164351, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+370
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+370
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+370
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '75', storedetaildate = '2024-12-12 10:58:29' WHERE storedetailid = '16297';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16298', '1', '2', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '10', '75', '2024-12-12 10:58:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35982;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('355','07234', '149067', '5', '16327', '1', '400', '400', '0', '', '1', '2024-12-12 10:58:29', '16327', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35982-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 355.00 , meanbuyprice = 355.00, lastbuyprice_withDiscount = 355.00, meanbuyprice_withDiscount = 355.00
        , lastbuyprice_withTax = 355, meanbuyprice_withTax = 355, lastbuyprice_withDiscountAndTax = 355
                where sellbilldetailid = 544687;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16327, '2024-12-12', 381.31288931481, 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+381.31288931481, 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-12', 381.31288931481, 355, 355
                    , 355, 355, 355, 355
                    , 0, 0, 0, 0
                    , 0, 0, 0, 355, 355, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+381.31288931481, 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 = '11', userid = '75', storedetaildate = '2024-12-12 10:58:29' WHERE storedetailid = '16326';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16327', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-12 10:58:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36119;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149067', '5', '16022', '1', '200', '200', '0', '', '1', '2024-12-12 10:58:29', '16022', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36119-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 = 544688;
 INSERT INTO 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-12', 190.6564446574, 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+190.6564446574, 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-12', 190.6564446574, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190.6564446574, 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 = '3', userid = '75', storedetaildate = '2024-12-12 10:58:29' WHERE storedetailid = '16021';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16022', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-12 10:58:29','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', '149067', '5', '16266', '1', '210', '210', '0', '', '1', '2024-12-12 10:58:29', '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 = 544689;
 INSERT INTO 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-12', 200.18926689027, 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.18926689027, 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-12', 200.18926689027, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200.18926689027, 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 = '16', userid = '75', storedetaildate = '2024-12-12 10:58:29' WHERE storedetailid = '16265';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16266', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '75', '2024-12-12 10:58:29','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', '149067', '5', '16301', '1', '200', '200', '0', '', '1', '2024-12-12 10:58:29', '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 = 544690;
 INSERT INTO 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-12', 190.6564446574, 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+190.6564446574, 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-12', 190.6564446574, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190.6564446574, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '75', storedetaildate = '2024-12-12 10:58:29' WHERE storedetailid = '16300';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16301', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-12 10:58:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35856;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('370','07180', '149067', '5', '16264', '1', '450', '450', '0', '', '1', '2024-12-12 10:58:29', '16264', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35856-1,','1','1','0','0','450','450','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 = 544691;
 INSERT INTO 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-12', 428.97700047916, 400, 400
                    , 387, 400, 387, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 400, 387, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+428.97700047916, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+387
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+387
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+387
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 428.97700047916, 400, 400
                    , 387, 400, 387, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 387, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+428.97700047916, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+387
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+387
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+387
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 10:58:29' WHERE storedetailid = '16263';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16264', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '75', '2024-12-12 10:58:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35939;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3323', '149067', '1', '16311', '1', '240', '240', '0', '', '1', '2024-12-12 10:58:29', '16311', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35939-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
        , lastbuyprice_withTax = 180, meanbuyprice_withTax = 180, lastbuyprice_withDiscountAndTax = 180
                where sellbilldetailid = 544692;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16311, '2024-12-12', 228.78773358888, 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+228.78773358888, 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-12', 228.78773358888, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+228.78773358888, 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 = '28', userid = '75', storedetaildate = '2024-12-12 10:58:29' WHERE storedetailid = '16310';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16311', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29', '28', '75', '2024-12-12 10:58:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35857;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('115','R3322', '149067', '1', '16265', '1', '165', '165', '0', '', '1', '2024-12-12 10:58:30', '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 = 544693;
 INSERT INTO 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-12', 157.29156684236, 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+157.29156684236, 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-12', 157.29156684236, 115, 115
                    , 115, 115, 115, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0, 115, 115, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+157.29156684236, 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 = '7', userid = '75', storedetaildate = '2024-12-12 10:58:30' WHERE storedetailid = '16264';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16265', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-12 10:58:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35882;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('245','R3326', '149067', '1', '16281', '1', '290', '290', '0', '', '1', '2024-12-12 10:58:30', '16281', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35882-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 245.00 , meanbuyprice = 245.00, lastbuyprice_withDiscount = 245.00, meanbuyprice_withDiscount = 245.00
        , lastbuyprice_withTax = 245, meanbuyprice_withTax = 245, lastbuyprice_withDiscountAndTax = 245
                where sellbilldetailid = 544694;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16281, '2024-12-12', 276.45184475323, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 245, 245, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+276.45184475323, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+245
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 276.45184475323, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 245, 245, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+276.45184475323, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+245
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '75', storedetaildate = '2024-12-12 10:58:30' WHERE storedetailid = '16280';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16281', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-12 10:58:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35810;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('370','H1607', '149067', '14', '16235', '2', '430', '860', '0', '', '1', '2024-12-12 10:58:30', '16235', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35810-2,','1','1','0','0','430','860','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 370.00 , meanbuyprice = 370.00, lastbuyprice_withDiscount = 370.00, meanbuyprice_withDiscount = 370.00
        , lastbuyprice_withTax = 370, meanbuyprice_withTax = 370, lastbuyprice_withDiscountAndTax = 370
                where sellbilldetailid = 544695;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16235, '2024-12-12', 819.82271202683, 740, 740
                    , 740, 740, 740, 740
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 740, 740, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+819.82271202683, sellCostBuyPrice =sellCostBuyPrice+740
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+740, sellCostMeanBuyPrice = sellCostMeanBuyPrice+740
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+740, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+740
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+740
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+740
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+740
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-12', 819.82271202683, 740, 740
                    , 740, 740, 740, 740
                    , 0, 0, 0, 0
                    , 0, 0, 0, 740, 740, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+819.82271202683, sellCostBuyPrice =sellCostBuyPrice+740
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+740, sellCostMeanBuyPrice = sellCostMeanBuyPrice+740
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+740, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+740
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+740
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+740
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+740
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 10:58:30' WHERE storedetailid = '16234';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16235', '1', '2', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '2', '75', '2024-12-12 10:58:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34801;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3203', '149067', '1', '15391', '1', '310', '310', '0', '', '1', '2024-12-12 10:58:30', '15391', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34801-1,','1','1','0','0','310','310','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 259.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 259.00
        , lastbuyprice_withTax = 260, meanbuyprice_withTax = 220, lastbuyprice_withDiscountAndTax = 260
                where sellbilldetailid = 544696;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15391, '2024-12-12', 295.51748921897, 260, 260
                    , 259, 260, 259, 256.82
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 260, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+295.51748921897, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+259
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+259
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+256.82
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , 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-12', 295.51748921897, 260, 260
                    , 259, 260, 259, 256.82
                    , 0, 0, 0, 0
                    , 0, 0, 0, 260, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+295.51748921897, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+259
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+259
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+256.82
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , 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 = '75', storedetaildate = '2024-12-12 10:58:30' WHERE storedetailid = '15390';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15391', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '75', '2024-12-12 10:58:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34668;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06866', '149067', '5', '15640', '1', '310', '310', '0', '', '1', '2024-12-12 10:58:30', '15640', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34668-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 = 544697;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15640, '2024-12-12', 295.51748921897, 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+295.51748921897, 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-12', 295.51748921897, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+295.51748921897, 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 = '75', storedetaildate = '2024-12-12 10:58:30' WHERE storedetailid = '15639';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15640', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-12 10:58:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35804;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07153', '149067', '5', '16213', '1', '210', '210', '0', '', '1', '2024-12-12 10:58:30', '16213', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35804-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 = 544698;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16213, '2024-12-12', 200.18926689027, 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.18926689027, 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-12', 200.18926689027, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200.18926689027, 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 = '19', userid = '75', storedetaildate = '2024-12-12 10:58:30' WHERE storedetailid = '16212';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16213', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '75', '2024-12-12 10:58:30','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', '149067', '5', '16189', '1', '220', '220', '0', '', '1', '2024-12-12 10:58:30', '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 = 544699;
 INSERT INTO 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-12', 209.72208912314, 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+209.72208912314, 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-12', 209.72208912314, 170, 170
                    , 170, 170, 170, 169.92
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+209.72208912314, 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 = '8', userid = '75', storedetaildate = '2024-12-12 10:58:30' WHERE storedetailid = '16188';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16189', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-12 10:58:30','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', '149067', '5', '15963', '1', '210', '210', '0', '', '1', '2024-12-12 10:58:30', '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 = 544700;
 INSERT INTO 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-12', 200.18926689027, 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+200.18926689027, 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-12', 200.18926689027, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200.18926689027, 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 = '4', userid = '75', storedetaildate = '2024-12-12 10:58:30' WHERE storedetailid = '15962';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15963', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 10:58:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35893;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('270','R3325', '149067', '1', '16290', '1', '290', '290', '0', '', '1', '2024-12-12 10:58:30', '16290', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35893-1,','1','1','0','0','290','290','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
        , lastbuyprice_withTax = 270, meanbuyprice_withTax = 270, lastbuyprice_withDiscountAndTax = 270
                where sellbilldetailid = 544701;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16290, '2024-12-12', 276.45184475323, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 270, 270, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+276.45184475323, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+270
                            , 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-12', 276.45184475323, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 270, 270, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+276.45184475323, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+270
                            , 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 = '10', userid = '75', storedetaildate = '2024-12-12 10:58:30' WHERE storedetailid = '16289';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16290', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-12 10:58:30','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', '149067', '5', '16297', '1', '580', '580', '0', '', '1', '2024-12-12 10:58:30', '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 = 544702;
 INSERT INTO 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-12', 552.90368950647, 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+552.90368950647, 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-12', 552.90368950647, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0, 510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+552.90368950647, 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 = '79', userid = '75', storedetaildate = '2024-12-12 10:58:30' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '80', '79', '75', '2024-12-12 10:58:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35825;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','07175', '149067', '5', '16241', '1', '300', '300', '0', '', '1', '2024-12-12 10:58:30', '16241', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35825-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 544703;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16241, '2024-12-12', 285.9846669861, 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+285.9846669861, 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-12', 285.9846669861, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+285.9846669861, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '75', storedetaildate = '2024-12-12 10:58:30' WHERE storedetailid = '16240';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16241', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-12 10:58:30','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', '149067', '14', '16259', '1', '360', '360', '0', '', '1', '2024-12-12 10:58:30', '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 = 544704;
 INSERT INTO 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-12', 343.18160038333, 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+343.18160038333, 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-12', 343.18160038333, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+343.18160038333, 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 = '15', userid = '75', storedetaildate = '2024-12-12 10:58:30' WHERE storedetailid = '16258';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16259', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '75', '2024-12-12 10:58:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35852;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1610', '149067', '14', '16261', '1', '480', '480', '0', '', '1', '2024-12-12 10:58:30', '16261', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35852-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where sellbilldetailid = 544705;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16261, '2024-12-12', 457.57546717777, 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+457.57546717777, 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-12', 457.57546717777, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+457.57546717777, 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 = '21', userid = '75', storedetaildate = '2024-12-12 10:58:30' WHERE storedetailid = '16260';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16261', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '75', '2024-12-12 10:58: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 ('575','H1402', '149067', '14', '15651', '1', '650', '650', '0', '', '1', '2024-12-12 10:58:30', '15651', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','650','650','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 575.00 , meanbuyprice = 575.00, lastbuyprice_withDiscount = 575.00, meanbuyprice_withDiscount = 575.00
        , lastbuyprice_withTax = 575, meanbuyprice_withTax = 575, lastbuyprice_withDiscountAndTax = 575
                where sellbilldetailid = 544706;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15651, '2024-12-12', 619.63344513656, 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.63344513656, 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-12', 619.63344513656, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0, 575, 575, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+619.63344513656, 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 = '0', userid = '75', storedetaildate = '2024-12-12 10:58:30' WHERE storedetailid = '15650';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15651', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-12 10:58:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34227;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149067', '5', '15165', '1', '190', '190', '0', '', '1', '2024-12-12 10:58:30', '15165', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34227-1,','1','1','0','0','190','190','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 665.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 665.00
        
                where sellbilldetailid = 544707;
 INSERT INTO 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-12', 181.12362242453, 140, 140
                    , 665, 140, 665, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+181.12362242453, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+665
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+665
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 181.12362242453, 140, 140
                    , 665, 140, 665, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+181.12362242453, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+665
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+665
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 10:58:30' WHERE storedetailid = '15164';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15165', '1', '1', '1', '149067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-12', '-13', '75', '2024-12-12 10:58: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', '149067', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 10:58:30', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149067', '17', '10291', '1', '83', '83', '0', '', '1', '2024-12-12 10:58:30', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','83','83','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 90 where clientid = 1257;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 7958, 6810, 6810
                    , 7321, 6810, 7321, 6791.03
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,6670, 6616, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7958, sellCostBuyPrice =sellCostBuyPrice+6810
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6810, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7321
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6810, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7321
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6791.03
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+6670
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+6616
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1257, '2024-12-12', 7958, 6810, 6810
                    , 7321, 6810, 7321, 6791.03
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,6670, 6616, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7958, sellCostBuyPrice =sellCostBuyPrice+6810
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6810, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7321
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6810, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7321
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6791.03
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+6670
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+6616
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 7958, 6810, 6810
                    , 7321, 6810, 7321, 6791.03, 6670, 6616)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+7958, netSellCostBuyPrice = netSellCostBuyPrice+6810
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+6810
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+7321
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+6810
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+7321
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+6791.03
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+6670
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+6616;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aa2f8bc8a7 and sellbillId = 149067 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675aa5b7727d9
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10572,@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-12 10:58:31', '0675aa5b7727d9', '10572', '-1000.00', '3035', '0', '1', '4035.00', '4035', '0', '4035', '1', '2024-12-12 10:59:57', '', '75', '0', 'عمرو مطرة 52', '2', '1', '3', '98', 'عمرو مطرة 52', '17' ,'0','','','','','-1','0','0','0','0','0','4035','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '3035', userid = '75' WHERE clientid = '10572';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10572','-1000.00','4035','0','اضافة فاتورة مبيعات','149068', '3035', '2024-12-12 10:59:57', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '4035', '0', null, '0', null, null,'', '0','1','1','4035','1','2024-12-12 10:58:31','0','0');
UPDATE client SET  inUse = 0 where clientid = 10572;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+11 where id = 35763;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+4 where id = 36104;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('242.67','06603', '149068', '5', '15038', '15', '265', '3975', '0', '', '1', '2024-12-12 10:59:57', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35763-11,36104-4,','1','1','0','0','265','3975','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 = 234, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 544710;
 INSERT INTO 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-12', 3975, 3600, 3600
                    , 3525, 3600, 3525, 3589.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 15, 0, 3600, 3510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3975, sellCostBuyPrice =sellCostBuyPrice+3600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3589.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3510
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+15
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 3975, 3600, 3600
                    , 3525, 3600, 3525, 3589.95
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3600, 3510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3975, sellCostBuyPrice =sellCostBuyPrice+3600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3589.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3510
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 10:59:57' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '15', '1', '149068', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '-7', '75', '2024-12-12 10:59:57','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149068', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 10:59:57', '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', '149068', '17', '10291', '1', '40', '40', '0', '', '1', '2024-12-12 10:59:57', '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 = 98 where clientid = 10572;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 4035, 3600, 3600
                    , 3525, 3600, 3525, 3589.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3600, 3510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4035, sellCostBuyPrice =sellCostBuyPrice+3600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3589.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3510
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10572, '2024-12-12', 4035, 3600, 3600
                    , 3525, 3600, 3525, 3589.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3600, 3510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4035, sellCostBuyPrice =sellCostBuyPrice+3600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3589.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3510
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 4035, 3600, 3600
                    , 3525, 3600, 3525, 3589.95, 3600, 3510)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+4035, netSellCostBuyPrice = netSellCostBuyPrice+3600
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3600
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+3525
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3600
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+3525
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+3589.95
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+3600
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+3510;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aa5b7727d9 and sellbillId = 149068 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675aa574741d3
-- ----------------------------------------------------------------------------------------------------

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-12 10:57:24', '0675aa574741d3', '1', '0.00', '0', '0', '1', '835.00', '835', '835', '0', '1', '2024-12-12 11:01:20', '', '104', '0', 'نقدي', '1', '0', '3', '54', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','835','0','','0','0','835','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149069', '0', '2024-12-12 11:01:20', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '835', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 10:57:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 23932;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','05048', '149069', '5', '10828', '1', '225', '225', '0', '', '1', '2024-12-12 11:01:20', '10828', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','23932-1,','1','1','0','0','225','225','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 = 544713;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10828, '2024-12-12', 225, 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+225, 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-12', 225, 340, 340
                    , 340, 340, 340, 340
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+225, 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 = '4', userid = '104', storedetaildate = '2024-12-12 11:01:20' WHERE storedetailid = '10827';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10828', '1', '1', '1', '149069', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-12 11:01:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31610;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2794', '149069', '1', '13908', '1', '185', '185', '0', '', '1', '2024-12-12 11:01:20', '13908', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31610-1,','1','1','0','0','185','185','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 260.00
        
                where sellbilldetailid = 544714;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13908, '2024-12-12', 185, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 185, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '104', storedetaildate = '2024-12-12 11:01:20' WHERE storedetailid = '13907';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13908', '1', '1', '1', '149069', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '104', '2024-12-12 11:01:20','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', '149069', '5', '16316', '1', '300', '300', '0', '', '1', '2024-12-12 11:01:20', '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 = 544715;
 INSERT INTO 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-12', 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-12', 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 = '26', userid = '104', storedetaildate = '2024-12-12 11:01:20' WHERE storedetailid = '16315';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16316', '1', '1', '1', '149069', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27', '26', '104', '2024-12-12 11:01:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34617;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0K783', '149069', '7', '15697', '1', '125', '125', '0', '', '1', '2024-12-12 11:01:20', '15697', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34617-1,','1','1','0','0','125','125','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 = 544716;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15697, '2024-12-12', 125, 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+125, 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-12', 125, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 160, 160, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, 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 = '1', userid = '104', storedetaildate = '2024-12-12 11:01:20' WHERE storedetailid = '15696';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15697', '1', '1', '1', '149069', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-12 11:01:20','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '1820',  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 ('985','835', '0', '1', 'اضافة فاتورة مبيعات', '149069', '1820', '2024-12-12 11:01:20', '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-12', 835, 985, 985
                    , 985, 985, 985, 985
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,385, 385, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+835, sellCostBuyPrice =sellCostBuyPrice+985
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+985, sellCostMeanBuyPrice = sellCostMeanBuyPrice+985
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+985, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+985
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+985
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+385
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 835, 985, 985
                    , 985, 985, 985, 985
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,385, 385, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+835, sellCostBuyPrice =sellCostBuyPrice+985
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+985, sellCostMeanBuyPrice = sellCostMeanBuyPrice+985
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+985, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+985
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+985
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+385
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 835, 985, 985
                    , 985, 985, 985, 985, 385, 385)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+835, netSellCostBuyPrice = netSellCostBuyPrice+985
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+985
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+985
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+985
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+985
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+985
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+385
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+385;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aa574741d3 and sellbillId = 149069 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675aa66100f9f
-- ----------------------------------------------------------------------------------------------------

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-12 11:01:21', '0675aa66100f9f', '1', '0.00', '0', '0', '1', '320.00', '320', '320', '0', '1', '2024-12-12 11:01:56', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149070', '0', '2024-12-12 11:01:56', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '320', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 11:01:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36028;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07209', '149070', '5', '16353', '1', '320', '320', '0', '', '1', '2024-12-12 11:01:56', '16353', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36028-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 270.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 270.00, meanbuyprice_withDiscount = 270.00
        , lastbuyprice_withTax = 270, meanbuyprice_withTax = 270, lastbuyprice_withDiscountAndTax = 270
                where sellbilldetailid = 544717;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16353, '2024-12-12', 320, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 270, 270, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+270
                            , 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-12', 320, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 270, 270, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+270
                            , 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 = '12', userid = '104', storedetaildate = '2024-12-12 11:01:56' WHERE storedetailid = '16352';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16353', '1', '1', '1', '149070', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '104', '2024-12-12 11:01:56','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2140',  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 ('1820','320', '0', '1', 'اضافة فاتورة مبيعات', '149070', '2140', '2024-12-12 11:01:56', '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-12', 320, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,270, 270, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+270
                            , 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-12', 320, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,270, 270, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+270
                            , 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, 320, 270, 270
                    , 270, 270, 270, 270, 270, 270)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+320, netSellCostBuyPrice = netSellCostBuyPrice+270
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+270
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+270
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+270
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+270
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+270
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+270
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+270;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aa66100f9f and sellbillId = 149070 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 07:31:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:01:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:01: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-12 07:41:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:11:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 11:11:33', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 07:41:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:11:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 11:11:51', '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-12', '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 = '2040',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('2140.00','100', '1', '1', 'إضافة مصروف', '25605', '2040', '2024-12-12 11:11:51', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'شركه كهربا', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-12', 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 = '25605';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 07:41:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:11:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 11:11: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-12 07:41:53";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:11:53", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 11:11:53', '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-12 07:43:37";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:13:37", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:13: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-12 07:44:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:14:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:14: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 0675aa941d46bb
-- ----------------------------------------------------------------------------------------------------

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-12 11:13:37', '0675aa941d46bb', '1', '0.00', '0', '0', '1', '290.00', '290', '290', '0', '1', '2024-12-12 11:14:10', '', '104', '0', 'نقدي', '1', '0', '3', '25', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','290','0','','0','0','290','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149071', '0', '2024-12-12 11:14:10', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '290', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 11:13:37','0','0');
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', '149071', '5', '16262', '1', '290', '290', '0', '', '1', '2024-12-12 11:14:10', '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 = 544718;
 INSERT INTO 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-12', 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-12', 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 = '11', userid = '104', storedetaildate = '2024-12-12 11:14:10' WHERE storedetailid = '16261';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16262', '1', '1', '1', '149071', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-12 11:14:10','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2330',  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 ('2040','290', '0', '1', 'اضافة فاتورة مبيعات', '149071', '2330', '2024-12-12 11:14:10', '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-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 290, 235, 235
                    , 235, 235, 235, 235, 235, 235)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+290, 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 0675aa941d46bb and sellbillId = 149071 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 07:44:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:14:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:14: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-12 07:46:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:16:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:16: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 0675aa963a1156
-- ----------------------------------------------------------------------------------------------------

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-12 11:14:11', '0675aa963a1156', '1', '0.00', '0', '0', '1', '480.00', '480', '480', '0', '1', '2024-12-12 11:16:54', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '2' ,'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-12','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','اضافة فاتورة مبيعات','149072', '0', '2024-12-12 11:16:54', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '480', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 11:14:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36004;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149072', '5', '15970', '1', '200', '200', '0', '', '1', '2024-12-12 11:16:54', '15970', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36004-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 = 128, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 544719;
 INSERT INTO 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-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 11:16:54' WHERE storedetailid = '15969';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15970', '1', '1', '1', '149072', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-1', '-2', '104', '2024-12-12 11:16:54','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35618;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1538', '149072', '14', '16012', '1', '280', '280', '0', '', '1', '2024-12-12 11:16:54', '16012', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35618-1,','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 = 544720;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16012, '2024-12-12', 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-12', 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 = '5', userid = '104', storedetaildate = '2024-12-12 11:16:54' WHERE storedetailid = '16011';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16012', '1', '1', '1', '149072', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-12 11:16:54','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '2810',  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 ('2330','480', '0', '1', 'اضافة فاتورة مبيعات', '149072', '2810', '2024-12-12 11:16:54', '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-12', 480, 350, 350
                    , 350, 350, 350, 350.62
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 338, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , 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-12', 480, 350, 350
                    , 350, 350, 350, 350.62
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 338, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , 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, 480, 350, 350
                    , 350, 350, 350, 350.62, 350, 338)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+480, netSellCostBuyPrice = netSellCostBuyPrice+350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+350
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+350
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+350
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+350
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+350.62
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+350
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+338;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aa963a1156 and sellbillId = 149072 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 07:46:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:16:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:16:54', '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 ('محمد سلمان 52' , '', '', '01280781063', '0', '', '0', '2024-12-12 11:23:20', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-12','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10678', '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 ('10678','0','0','0','إضافة عميل جديد','10678', '0', '2024-12-12 11: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 ('محمد سلمان 52', 'محمد سلمان 52', 'محمد سلمان 52', 'محمد سلمان 52', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-12 11:23:20');
UPDATE client SET clientname = 'محمد سلمان 52', clientaddress = '', clientphone = '', clientmobile = '01280781063', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-12', 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='12409',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10678';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 07:54:06";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 11:24:06", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:24: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 0675aa60e47fbd
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10678,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-12 10:59:58', '0675aa60e47fbd', '10678', '0.00', '677', '0', '1', '677.00', '677', '0', '677', '1', '2024-12-12 11:24:06', '', '75', '0', 'محمد سلمان 52', '2', '1', '3', '98', 'محمد سلمان 52', '3' ,'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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '677', userid = '75' WHERE clientid = '10678';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10678','0.00','677','0','اضافة فاتورة مبيعات','149073', '677', '2024-12-12 11:24:06', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '677', '0', null, '0', null, null,'', '0','1','1','677','1','2024-12-12 10:59:58','0','0');
UPDATE client SET  inUse = 0 where clientid = 10678;
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', '149073', '1', '16277', '1', '650', '650', '0', '', '1', '2024-12-12 11:24:06', '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 = 544721;
 INSERT INTO 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-12', 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-12', 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 = '81', userid = '75', storedetaildate = '2024-12-12 11:24:06' WHERE storedetailid = '16276';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16277', '1', '1', '1', '149073', 'اضافة فاتورة مبيعات', 'sellbillController.php', '82', '81', '75', '2024-12-12 11:24: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', '149073', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 11:24: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', '149073', '17', '10291', '1', '7', '7', '0', '', '1', '2024-12-12 11:24:06', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','7','7','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 98 where clientid = 10678;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 677, 550, 550
                    , 549, 550, 547, 546.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 548, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+677, 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 (10678, '2024-12-12', 677, 550, 550
                    , 549, 550, 547, 546.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,550, 548, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+677, 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, 677, 550, 550
                    , 549, 550, 547, 546.67, 550, 548)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+677, 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 0675aa60e47fbd and sellbillId = 149073 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 07:54:06";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 11:24:07", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:24: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-12 08:00:09";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 11:30:09", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:30: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 0675aabb732083
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6378,@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-12 11:24:07', '0675aabb732083', '6378', '0.00', '253', '0', '1', '253.00', '253', '0', '253', '1', '2024-12-12 11:30:09', '', '75', '0', 'مريم سعد y118', '2', '1', '3', '80', 'مريم سعد y118', '3' ,'0','','','','','-1','0','0','0','0','0','253','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '253', userid = '75' WHERE clientid = '6378';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6378','0.00','253','0','اضافة فاتورة مبيعات','149074', '253', '2024-12-12 11:30:09', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '253', '0', null, '0', null, null,'', '0','1','1','253','1','2024-12-12 11:24:07','0','0');
UPDATE client SET  inUse = 0 where clientid = 6378;
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', '149074', '5', '16004', '1', '230', '230', '0', '', '1', '2024-12-12 11:30:09', '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 = 544724;
 INSERT INTO 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-12', 230, 165, 165
                    , 164, 165, 164, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+164
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+164
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+175
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 230, 165, 165
                    , 164, 165, 164, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+164
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+164
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+175
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+155
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-12 11:30:09' WHERE storedetailid = '16003';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16004', '1', '1', '1', '149074', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-12 11:30: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', '149074', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 11:30: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', '149074', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-12 11:30:09', '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 = 6378;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 253, 165, 165
                    , 164, 165, 164, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,165, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+253, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6378, '2024-12-12', 253, 165, 165
                    , 164, 165, 164, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,165, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+253, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 253, 165, 165
                    , 164, 165, 164, 175, 165, 155)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+253, netSellCostBuyPrice = netSellCostBuyPrice+165
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+165
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+164
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+165
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+164
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+175
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+165
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+155;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aabb732083 and sellbillId = 149074 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:00:10";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 11:30:10", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:30: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-12 08:01:16";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 11:31:16", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:31: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 0675aad2275688
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(569,@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-12 11:30:10', '0675aad2275688', '569', '-1.00', '605', '0', '1', '606.00', '606', '0', '606', '1', '2024-12-12 11:31:16', '', '75', '0', 'ميرا عزت بني سويف s6', '2', '1', '3', '80', 'ميرا عزت بني سويف s6', '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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '605', userid = '75' WHERE clientid = '569';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('569','-1.00','606','0','اضافة فاتورة مبيعات','149075', '605', '2024-12-12 11:31:16', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '606', '0', null, '0', null, null,'', '0','1','1','606','1','2024-12-12 11:30:10','0','0');
UPDATE client SET  inUse = 0 where clientid = 569;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35732;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('480','H1596', '149075', '14', '16219', '1', '580', '580', '0', '', '1', '2024-12-12 11:31:16', '16219', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35732-1,','1','1','0','0','580','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 480.00 , meanbuyprice = 480.00, lastbuyprice_withDiscount = 480.00, meanbuyprice_withDiscount = 480.00
        , lastbuyprice_withTax = 480, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 480
                where sellbilldetailid = 544727;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16219, '2024-12-12', 580, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 580, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '75', storedetaildate = '2024-12-12 11:31:16' WHERE storedetailid = '16218';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16219', '1', '1', '1', '149075', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-12 11:31: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', '149075', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 11:31: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', '149075', '17', '10291', '1', '6', '6', '0', '', '1', '2024-12-12 11:31:17', '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 = 569;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 606, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+606, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (569, '2024-12-12', 606, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+606, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 606, 480, 480
                    , 480, 480, 480, 480, 480, 480)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+606, netSellCostBuyPrice = netSellCostBuyPrice+480
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+480
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+480
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+480
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+480
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+480
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+480
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+480;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aad2275688 and sellbillId = 149075 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:01:17";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 11:31:17", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:31:17', '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-12 08:02:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:32:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:32: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-12 08:03:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:33:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:33: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 0675aaa0720fa5
-- ----------------------------------------------------------------------------------------------------

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-12 11:16:55', '0675aaa0720fa5', '1', '0.00', '0', '0', '1', '3080.00', '3080', '3080', '0', '1', '2024-12-12 11:33:48', '', '104', '0', 'نقدي', '1', '0', '3', '92', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','3080','0','','0','0','3080','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149076', '0', '2024-12-12 11:33:48', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3080', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 11:16:55','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34820;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('360','R3275', '149076', '1', '15818', '1', '420', '420', '0', '', '1', '2024-12-12 11:33:48', '15818', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34820-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 544730;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15818, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '104', storedetaildate = '2024-12-12 11:33:48' WHERE storedetailid = '15817';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15818', '1', '1', '1', '149076', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '104', '2024-12-12 11:33:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36267;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3306', '149076', '1', '16080', '1', '500', '500', '0', '', '1', '2024-12-12 11:33:48', '16080', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36267-1,','1','1','0','0','500','500','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 357.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 357.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 353, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 544731;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16080, '2024-12-12', 500, 360, 360
                    , 357, 360, 357, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 353, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+357
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+357
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+353
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 500, 360, 360
                    , 357, 360, 357, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 353, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+357
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+357
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+353
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '21', userid = '104', storedetaildate = '2024-12-12 11:33:48' WHERE storedetailid = '16079';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16080', '1', '1', '1', '149076', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '104', '2024-12-12 11:33:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35582;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('1050','H1539', '149076', '14', '16018', '1', '1350', '1350', '0', '', '1', '2024-12-12 11:33:48', '16018', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35582-1,','1','1','0','0','1350','1350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 1050.00 , meanbuyprice = 1052.00, lastbuyprice_withDiscount = 1050.00, meanbuyprice_withDiscount = 1052.00
        , lastbuyprice_withTax = 1050, meanbuyprice_withTax = 1055, lastbuyprice_withDiscountAndTax = 1050
                where sellbilldetailid = 544732;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16018, '2024-12-12', 1350, 1050, 1050
                    , 1052, 1050, 1052, 1075
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 1050, 1055, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1350, sellCostBuyPrice =sellCostBuyPrice+1050
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1050, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1052
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1050, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1052
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1075
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1050
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1055
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 1350, 1050, 1050
                    , 1052, 1050, 1052, 1075
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1050, 1055, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1350, sellCostBuyPrice =sellCostBuyPrice+1050
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1050, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1052
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1050, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1052
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1075
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1050
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1055
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 11:33:48' WHERE storedetailid = '16017';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16018', '1', '1', '1', '149076', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-12 11:33:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35837;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149076', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-12 11:33:48', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35837-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 = 544733;
 INSERT INTO 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-12', 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-12', 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 = '79', userid = '104', storedetaildate = '2024-12-12 11:33:48' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '149076', 'اضافة فاتورة مبيعات', 'sellbillController.php', '80', '79', '104', '2024-12-12 11:33:48','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '5890',  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 ('2810','3080', '0', '1', 'اضافة فاتورة مبيعات', '149076', '5890', '2024-12-12 11:33:48', '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-12', 3080, 2500, 2500
                    , 2499, 2500, 2499, 2550
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2500, 2498, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3080, sellCostBuyPrice =sellCostBuyPrice+2500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2499
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2499
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2498
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 3080, 2500, 2500
                    , 2499, 2500, 2499, 2550
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2500, 2498, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3080, sellCostBuyPrice =sellCostBuyPrice+2500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2499
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2499
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2500
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2498
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3080, 2500, 2500
                    , 2499, 2500, 2499, 2550, 2500, 2498)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3080, netSellCostBuyPrice = netSellCostBuyPrice+2500
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2500
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2499
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2500
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2499
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2550
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2500
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2498;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aaa0720fa5 and sellbillId = 149076 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:03:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:33:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:33: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-12 08:05:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:35:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:35: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 0675aadbf17edc
-- ----------------------------------------------------------------------------------------------------

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-12 11:32:47', '0675aadbf17edc', '1', '0.00', '0', '0', '1', '315.00', '315', '315', '0', '1', '2024-12-12 11:35:40', '', '104', '0', 'نقدي', '1', '0', '3', '24', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','315','0','','0','0','315','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149077', '0', '2024-12-12 11:35:40', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '315', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 11:32: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 ('310','0H836', '149077', '14', '8855', '1', '315', '315', '0', '', '1', '2024-12-12 11:35:40', '8855', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','315','315','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 310.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 310.00
        
                where sellbilldetailid = 544734;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8855, '2024-12-12', 315, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+315, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 315, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+315, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '104', storedetaildate = '2024-12-12 11:35:40' WHERE storedetailid = '8854';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('8855', '1', '1', '1', '149077', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-12 11:35:40','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '6205',  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 ('5890','315', '0', '1', 'اضافة فاتورة مبيعات', '149077', '6205', '2024-12-12 11:35:40', '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-12', 315, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+315, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 315, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+315, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 315, 310, 310
                    , 310, 310, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+315, netSellCostBuyPrice = netSellCostBuyPrice+310
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+310
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+310
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+310
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+310
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+310
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aadbf17edc and sellbillId = 149077 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:05:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:35:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:35: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-12 08:07:43";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:37:43", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:37: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-12 08:10:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:40:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:40: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 0675aaee76f82e
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(862,@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-12 11:37:43', '0675aaee76f82e', '862', '0.00', '1515', '0', '1', '1515.00', '1515', '0', '1515', '1', '2024-12-12 11:40:10', '', '104', '0', 'اميرة حسن S5', '1', '1', '3', '24', 'اميرة حسن S5', '4' ,'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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1515', userid = '104' WHERE clientid = '862';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('862','0.00','1515','0','اضافة فاتورة مبيعات','149078', '1515', '2024-12-12 11:40:10', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1515', '0', null, '0', null, null,'', '0','1','1','1515','1','2024-12-12 11:37:43','0','0');
UPDATE client SET  inUse = 0 where clientid = 862;
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', '149078', '5', '15654', '1', '360', '360', '0', '', '1', '2024-12-12 11:40:10', '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 = 544735;
 INSERT INTO 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-12', 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-12', 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 = '7', userid = '104', storedetaildate = '2024-12-12 11:40:10' WHERE storedetailid = '15653';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15654', '1', '1', '1', '149078', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '104', '2024-12-12 11:40:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35957;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149078', '5', '16275', '1', '330', '330', '0', '', '1', '2024-12-12 11:40:10', '16275', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35957-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 = 282, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 544736;
 INSERT INTO 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-12', 330, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 280, 282, 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+282
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 330, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 282, 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+282
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '44', userid = '104', storedetaildate = '2024-12-12 11:40:10' WHERE storedetailid = '16274';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16275', '1', '1', '1', '149078', 'اضافة فاتورة مبيعات', 'sellbillController.php', '45', '44', '104', '2024-12-12 11:40:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35837;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149078', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-12 11:40:10', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35837-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 = 544737;
 INSERT INTO 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-12', 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-12', 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 = '78', userid = '104', storedetaildate = '2024-12-12 11:40:10' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '149078', 'اضافة فاتورة مبيعات', 'sellbillController.php', '79', '78', '104', '2024-12-12 11:40: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', '149078', '17', '10291', '1', '15', '15', '0', '', '1', '2024-12-12 11:40:10', '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 = 24 where clientid = 862;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1515, 1305, 1305
                    , 1124, 1305, 1124, 1305
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1305, 1125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1515, sellCostBuyPrice =sellCostBuyPrice+1305
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1305, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1124
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1305, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1124
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1305
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1305
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1125
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (862, '2024-12-12', 1515, 1305, 1305
                    , 1124, 1305, 1124, 1305
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1305, 1125, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1515, sellCostBuyPrice =sellCostBuyPrice+1305
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1305, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1124
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1305, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1124
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1305
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1305
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1125
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 1305, 1305
                    , 1124, 1305, 1124, 1305, 1305, 1125)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1515, netSellCostBuyPrice = netSellCostBuyPrice+1305
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1305
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1124
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1305
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1124
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1305
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1305
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1125;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aaee76f82e and sellbillId = 149078 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:10:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:40:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:40: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-12 08:15:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:45:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:45: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 0675aaf7b71b32
-- ----------------------------------------------------------------------------------------------------

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-12 11:40:11', '0675aaf7b71b32', '1', '0.00', '0', '0', '1', '800.00', '800', '800', '0', '1', '2024-12-12 11:45:46', '', '104', '0', 'نقدي', '1', '0', '3', '71', 'نقدي', '1' ,'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-12','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','اضافة فاتورة مبيعات','149079', '0', '2024-12-12 11:45:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '800', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 11:40:11','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', '149079', '14', '16364', '1', '800', '800', '0', '', '1', '2024-12-12 11:45:46', '16364', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36084-1,','1','1','0','0','800','800','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 = 544739;
 INSERT INTO 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-12', 800, 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+800, 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-12', 800, 600, 600
                    , 600, 600, 600, 600
                    , 0, 0, 0, 0
                    , 0, 0, 0, 600, 600, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, 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 = '9', userid = '104', storedetaildate = '2024-12-12 11:45:46' WHERE storedetailid = '16363';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16364', '1', '1', '1', '149079', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-12 11:45:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '7005',  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 ('6205','800', '0', '1', 'اضافة فاتورة مبيعات', '149079', '7005', '2024-12-12 11:45:46', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 71 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-12', 800, 600, 600
                    , 600, 600, 600, 600
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,600, 600, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+600
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+600
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 800, 600, 600
                    , 600, 600, 600, 600
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,600, 600, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+600
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+600
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 800, 600, 600
                    , 600, 600, 600, 600, 600, 600)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+800, netSellCostBuyPrice = netSellCostBuyPrice+600
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+600
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+600
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+600
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+600
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+600
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+600
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+600;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aaf7b71b32 and sellbillId = 149079 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ab16015396
-- ----------------------------------------------------------------------------------------------------

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-12 11:48:16', '0675ab16015396', '1', '0.00', '0', '0', '1', '635.00', '635', '635', '0', '1', '2024-12-12 11:49:52', '', '9', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','635','0','','0','0','635','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149080', '0', '2024-12-12 11:49:52', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '635', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 11:48:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34515;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06817', '149080', '5', '15519', '1', '225', '225', '0', '', '1', '2024-12-12 11:49:52', '15519', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34515-1,','1','1','0','0','225','225','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 = 147, lastbuyprice_withDiscountAndTax = 235
                where sellbilldetailid = 544740;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15519, '2024-12-12', 225, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 235, 147, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+225, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+147
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 225, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 147, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+225, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+147
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '9', storedetaildate = '2024-12-12 11:49:52' WHERE storedetailid = '15518';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15519', '1', '1', '1', '149080', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '9', '2024-12-12 11:49:52','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35845;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1617', '149080', '14', '16253', '1', '410', '410', '0', '', '1', '2024-12-12 11:49:52', '16253', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35845-1,','1','1','0','0','410','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 304.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 304.00
        , lastbuyprice_withTax = 300, meanbuyprice_withTax = 302, lastbuyprice_withDiscountAndTax = 300
                where sellbilldetailid = 544741;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16253, '2024-12-12', 410, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+302
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 410, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+302
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '9', storedetaildate = '2024-12-12 11:49:52' WHERE storedetailid = '16252';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16253', '1', '1', '1', '149080', 'اضافة فاتورة مبيعات', 'sellbillController.php', '43', '42', '9', '2024-12-12 11:49:52','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '7640',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7005','635', '0', '1', 'اضافة فاتورة مبيعات', '149080', '7640', '2024-12-12 11:49:52', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 97 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 635, 535, 535
                    , 539, 535, 539, 536.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,535, 449, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+635, sellCostBuyPrice =sellCostBuyPrice+535
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+535, sellCostMeanBuyPrice = sellCostMeanBuyPrice+539
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+539
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+536.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+535
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+449
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 635, 535, 535
                    , 539, 535, 539, 536.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,535, 449, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+635, sellCostBuyPrice =sellCostBuyPrice+535
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+535, sellCostMeanBuyPrice = sellCostMeanBuyPrice+539
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+539
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+536.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+535
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+449
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 635, 535, 535
                    , 539, 535, 539, 536.5, 535, 449)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+635, netSellCostBuyPrice = netSellCostBuyPrice+535
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+535
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+539
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+535
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+539
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+536.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+535
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+449;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab16015396 and sellbillId = 149080 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:19:53";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 11:49:53", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 11:49:53', '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-12 08:30:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:00:07", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:00:07', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ab1c15cf90
-- ----------------------------------------------------------------------------------------------------

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-12 11:49:53', '0675ab1c15cf90', '1', '0.00', '0', '0', '1', '420.00', '420', '420', '0', '1', '2024-12-12 12:00:07', '', '9', '0', 'نقدي', '1', '0', '3', '95', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','420','0','','0','0','420','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149081', '0', '2024-12-12 12:00:07', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '420', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 11:49:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35869;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07190', '149081', '5', '16273', '1', '420', '420', '0', '', '1', '2024-12-12 12:00:07', '16273', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35869-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 = 544742;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16273, '2024-12-12', 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-12', 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 = '9', storedetaildate = '2024-12-12 12:00:07' WHERE storedetailid = '16272';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16273', '1', '1', '1', '149081', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '9', '2024-12-12 12:00:07','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '8060',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('7640','420', '0', '1', 'اضافة فاتورة مبيعات', '149081', '8060', '2024-12-12 12:00:07', '9',  '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-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 420, 365, 365
                    , 365, 365, 365, 365, 365, 365)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+420, netSellCostBuyPrice = netSellCostBuyPrice+365
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+365
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+365
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+365
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+365
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+365
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+365
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+365;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab1c15cf90 and sellbillId = 149081 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:30:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:00:07", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:00:07', '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-12 08:34:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:04:15", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:04:15', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ab42826dfa
-- ----------------------------------------------------------------------------------------------------

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-12 12:00:08', '0675ab42826dfa', '1', '0.00', '0', '0', '1', '175.00', '175', '175', '0', '1', '2024-12-12 12:04:15', '', '9', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','175','0','','0','0','175','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149082', '0', '2024-12-12 12:04:15', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '175', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 12:00: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 ('230','00D20', '149082', '1', '12938', '1', '175', '175', '0', '', '1', '2024-12-12 12:04:16', '12938', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','175','175','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 = 544743;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12938, '2024-12-12', 175, 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+175, 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-12', 175, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+175, 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 = '9', storedetaildate = '2024-12-12 12:04:16' WHERE storedetailid = '12937';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12938', '1', '1', '1', '149082', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '9', '2024-12-12 12:04:16','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '8235',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8060','175', '0', '1', 'اضافة فاتورة مبيعات', '149082', '8235', '2024-12-12 12:04:16', '9',  '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-12', 175, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+175, 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;
 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-12', 175, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+175, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 175, 230, 230
                    , 230, 230, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+175, netSellCostBuyPrice = netSellCostBuyPrice+230
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+230
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+230
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+230
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+230
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+230
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab42826dfa and sellbillId = 149082 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675aad65af40b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9747,@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-12 11:31:17', '0675aad65af40b', '9747', '0.00', '3000', '0', '1', '3000.00', '3000', '0', '3000', '1', '2024-12-12 12:04:42', '', '75', '0', 'رحمة ياسر', '2', '1', '3', '90', 'رحمة ياسر', '12' ,'0','','','','','-1','0','0','0','0','0','3000','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '3000', userid = '75' WHERE clientid = '9747';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9747','0.00','3000','0','اضافة فاتورة مبيعات','149083', '3000', '2024-12-12 12:04:42', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3000', '0', null, '0', null, null,'', '0','1','1','3000','1','2024-12-12 11:31:17','0','0');
UPDATE client SET  inUse = 0 where clientid = 9747;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35810;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('370','H1607', '149083', '14', '16235', '1', '430', '430', '0', '', '1', '2024-12-12 12:04:42', '16235', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35810-1,','1','1','0','0','430','430','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 370.00 , meanbuyprice = 370.00, lastbuyprice_withDiscount = 370.00, meanbuyprice_withDiscount = 370.00
        , lastbuyprice_withTax = 370, meanbuyprice_withTax = 370, lastbuyprice_withDiscountAndTax = 370
                where sellbilldetailid = 544744;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16235, '2024-12-12', 430, 370, 370
                    , 370, 370, 370, 370
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 370, 370, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+370
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+370
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+370
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 430, 370, 370
                    , 370, 370, 370, 370
                    , 0, 0, 0, 0
                    , 0, 0, 0, 370, 370, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+370
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+370
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+370
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-12 12:04:42' WHERE storedetailid = '16234';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16235', '1', '1', '1', '149083', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-12 12:04:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35820;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07171', '149083', '5', '16238', '1', '300', '300', '0', '', '1', '2024-12-12 12:04:42', '16238', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35820-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 = 544745;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16238, '2024-12-12', 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-12', 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-12 12:04:42' WHERE storedetailid = '16237';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16238', '1', '1', '1', '149083', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-12 12:04:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35567;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149083', '5', '15673', '2', '360', '720', '0', '', '1', '2024-12-12 12:04:42', '15673', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35567-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 = 544746;
 INSERT INTO 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-12', 720, 590, 590
                    , 590, 590, 590, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 590, 590, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+590
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+590
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+590
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+590
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+590
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 720, 590, 590
                    , 590, 590, 590, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0, 590, 590, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+590
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+590
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+590
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+590
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+590
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '22', userid = '75', storedetaildate = '2024-12-12 12:04:42' WHERE storedetailid = '15672';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15673', '1', '2', '1', '149083', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '22', '75', '2024-12-12 12:04:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35593;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149083', '5', '15850', '2', '240', '480', '0', '', '1', '2024-12-12 12:04:42', '15850', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35593-2,','1','1','0','0','240','480','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 = 544747;
 INSERT INTO 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-12', 480, 380, 380
                    , 380, 380, 380, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 380, 376, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+376
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-12', 480, 380, 380
                    , 380, 380, 380, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 380, 376, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+376
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:04:42' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '2', '1', '149083', 'اضافة فاتورة مبيعات', 'sellbillController.php', '69', '67', '75', '2024-12-12 12:04:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35961;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07142', '149083', '5', '16181', '1', '250', '250', '0', '', '1', '2024-12-12 12:04:42', '16181', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35961-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 191.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 191.00
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 191, lastbuyprice_withDiscountAndTax = 190
                where sellbilldetailid = 544748;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16181, '2024-12-12', 250, 190, 190
                    , 191, 190, 191, 192.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 190, 191, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+191
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+191
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+192.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+191
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 250, 190, 190
                    , 191, 190, 191, 192.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 191, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+191
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+191
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+192.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+191
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:04:42' WHERE storedetailid = '16180';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16181', '1', '1', '1', '149083', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-12 12:04:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35690;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07148', '149083', '5', '16194', '1', '260', '260', '0', '', '1', '2024-12-12 12:04:42', '16194', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35690-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 = 544749;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16194, '2024-12-12', 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-12', 260, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+210
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+210, sellCostMeanBuyPrice = sellCostMeanBuyPrice+210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+210, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+210
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+210
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+210
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '75', storedetaildate = '2024-12-12 12:04:42' WHERE storedetailid = '16193';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16194', '1', '1', '1', '149083', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-12 12:04:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35435;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3301', '149083', '1', '16051', '1', '210', '210', '0', '', '1', '2024-12-12 12:04:42', '16051', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35435-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 = 544750;
 INSERT INTO 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-12', 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-12', 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 = '3', userid = '75', storedetaildate = '2024-12-12 12:04:42' WHERE storedetailid = '16050';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16051', '1', '1', '1', '149083', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-12 12:04:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35801;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149083', '5', '16224', '1', '300', '300', '0', '', '1', '2024-12-12 12:04:42', '16224', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35801-1,','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 = 544751;
 INSERT INTO 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-12', 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-12', 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 = '4', userid = '75', storedetaildate = '2024-12-12 12:04:43' WHERE storedetailid = '16223';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16224', '1', '1', '1', '149083', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 12:04:43','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149083', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 12:04:43', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149083', '17', '10291', '1', '30', '30', '0', '', '1', '2024-12-12 12:04:43', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','30','30','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 90 where clientid = 9747;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 3000, 2385, 2385
                    , 2389, 2385, 2389, 2394.17
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2385, 2388, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3000, sellCostBuyPrice =sellCostBuyPrice+2385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2389
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2389
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2394.17
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2388
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9747, '2024-12-12', 3000, 2385, 2385
                    , 2389, 2385, 2389, 2394.17
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2385, 2388, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3000, sellCostBuyPrice =sellCostBuyPrice+2385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2389
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2389
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2394.17
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2388
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3000, 2385, 2385
                    , 2389, 2385, 2389, 2394.17, 2385, 2388)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3000, netSellCostBuyPrice = netSellCostBuyPrice+2385
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2385
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2389
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2385
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2389
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2394.17
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2385
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2388;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aad65af40b and sellbillId = 149083 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ab53bc1c8b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7607,@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-12 12:04:43', '0675ab53bc1c8b', '7607', '0.00', '273', '0', '1', '273.00', '273', '0', '273', '1', '2024-12-12 12:05:59', '', '75', '0', 'اسراء السيد E900', '2', '1', '3', '78', 'اسراء السيد E900', '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-12','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 = '7607';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7607','0.00','273','0','اضافة فاتورة مبيعات','149084', '273', '2024-12-12 12:05:59', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '273', '0', null, '0', null, null,'', '0','1','1','273','1','2024-12-12 12:04:43','0','0');
UPDATE client SET  inUse = 0 where clientid = 7607;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35687;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('195','07145', '149084', '5', '16191', '1', '250', '250', '0', '', '1', '2024-12-12 12:05:59', '16191', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35687-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 195.00, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 195.00
        , lastbuyprice_withTax = 195, meanbuyprice_withTax = 195, lastbuyprice_withDiscountAndTax = 195
                where sellbilldetailid = 544754;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16191, '2024-12-12', 250, 195, 195
                    , 195, 195, 195, 194.91
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 195, 195, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+194.91
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+195
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+195
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 250, 195, 195
                    , 195, 195, 195, 194.91
                    , 0, 0, 0, 0
                    , 0, 0, 0, 195, 195, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+194.91
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+195
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+195
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:05:59' WHERE storedetailid = '16190';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16191', '1', '1', '1', '149084', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-12 12:05:59','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149084', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 12:05:59', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149084', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-12 12:05:59', '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 = 78 where clientid = 7607;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 273, 195, 195
                    , 195, 195, 195, 194.91
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,195, 195, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+273, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+194.91
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+195
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+195
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7607, '2024-12-12', 273, 195, 195
                    , 195, 195, 195, 194.91
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,195, 195, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+273, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+194.91
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+195
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+195
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 195, 195
                    , 195, 195, 195, 194.91, 195, 195)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+273, netSellCostBuyPrice = netSellCostBuyPrice+195
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+195
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+195
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+195
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+195
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+194.91
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+195
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+195;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab53bc1c8b and sellbillId = 149084 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ab520abf19
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6327,@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-12 12:04:16', '0675ab520abf19', '6327', '0.00', '818', '0', '1', '818.00', '818', '0', '818', '1', '2024-12-12 12:08:35', '', '9', '0', 'اميرة شلبي 14', '1', '1', '3', '97', 'اميرة شلبي 14', '3' ,'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-12','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '818', userid = '9' WHERE clientid = '6327';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6327','0.00','818','0','اضافة فاتورة مبيعات','149085', '818', '2024-12-12 12:08:35', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '818', '0', null, '0', null, null,'', '0','1','1','818','1','2024-12-12 12:04:16','0','0');
UPDATE client SET  inUse = 0 where clientid = 6327;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35630;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('350','07108', '149085', '5', '16174', '1', '410', '410', '0', '', '0', '2024-12-12 12:08:35', '16174', '0.00', '-1', '1','0','','','0','0','0','0','0','0','0','0','','35630-1,','1','1','0','0','410','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 350, lastbuyprice_withDiscountAndTax = 350
                where sellbilldetailid = 544757;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16174, '2024-12-12', 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-12', 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 = '23', userid = '9', storedetaildate = '2024-12-12 12:08:35' WHERE storedetailid = '16173';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16174', '1', '1', '1', '149085', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '9', '2024-12-12 12:08:35','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', '149085', '1', '15763', '1', '400', '400', '0', '', '0', '2024-12-12 12:08:35', '15763', '0.00', '-1', '1','0','','','0','0','0','0','0','0','0','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 = 544758;
 INSERT INTO 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-12', 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-12', 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 = '15', userid = '9', storedetaildate = '2024-12-12 12:08:35' WHERE storedetailid = '15762';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15763', '1', '1', '1', '149085', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '9', '2024-12-12 12:08: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 ('0','10291', '149085', '17', '10291', '1', '8', '8', '0', '', '0', '2024-12-12 12:08:35', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','0','0','','','1','1','0','0','8','8','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 97 where clientid = 6327;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 818, 690, 690
                    , 690, 690, 690, 685
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,690, 690, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+818, sellCostBuyPrice =sellCostBuyPrice+690
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+690, sellCostMeanBuyPrice = sellCostMeanBuyPrice+690
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+690, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+690
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+685
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+690
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+690
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6327, '2024-12-12', 818, 690, 690
                    , 690, 690, 690, 685
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,690, 690, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+818, sellCostBuyPrice =sellCostBuyPrice+690
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+690, sellCostMeanBuyPrice = sellCostMeanBuyPrice+690
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+690, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+690
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+685
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+690
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+690
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 690, 690
                    , 690, 690, 690, 685, 690, 690)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+818, netSellCostBuyPrice = netSellCostBuyPrice+690
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+690
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+690
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+690
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+690
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+685
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+690
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+690;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab520abf19 and sellbillId = 149085 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:38:35";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:08:35", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:08:35', '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 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-12 08:39:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:09:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 12:09:06', '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-12 08:39:07";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:40:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:10:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 12:10: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-12 08:40:18";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:10:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 12:10:18', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:40:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:10:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 12:10:22', '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-12', '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 = '8185',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('8235.00','50', '1', '1', 'إضافة مصروف', '25606', '8185', '2024-12-12 12:10:22', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'دنيا', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25606';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:40:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:10:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 12:10:22', '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-12 08:40:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:10:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 12:10:24', '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-12 08:40:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:10:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 12:10:26', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:40:34";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:10:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 12:10:34', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:40:45";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:10:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:10:45', '2', 'showDetail', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=110919');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:40:49";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:10:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:10:49', '2', 'showDetail', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=136343');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:41:04";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:11:04", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:11:04', '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-12 08:42:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:12:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12: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 0675ab6b873c2c
-- ----------------------------------------------------------------------------------------------------

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-12 12:11:04', '0675ab6b873c2c', '1', '0.00', '0', '0', '1', '455.00', '455', '455', '0', '1', '2024-12-12 12:12:10', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','455','0','','0','0','455','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149086', '0', '2024-12-12 12:12:10', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '455', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 12:11: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 ('445','05730', '149086', '5', '12495', '1', '255', '255', '0', '', '1', '2024-12-12 12:12:10', '12495', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','255','255','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 = 544760;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12495, '2024-12-12', 255, 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+255, 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-12', 255, 445, 445
                    , 445, 445, 445, 445
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+255, sellCostBuyPrice =sellCostBuyPrice+445
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+445, sellCostMeanBuyPrice = sellCostMeanBuyPrice+445
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+445, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+445
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+445
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-1', userid = '104', storedetaildate = '2024-12-12 12:12:10' WHERE storedetailid = '12494';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12495', '1', '1', '1', '149086', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '104', '2024-12-12 12:12:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35861;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','07187', '149086', '5', '16267', '1', '200', '200', '0', '', '1', '2024-12-12 12:12:10', '16267', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35861-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 544761;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16267, '2024-12-12', 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-12', 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 = '10', userid = '104', storedetaildate = '2024-12-12 12:12:10' WHERE storedetailid = '16266';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16267', '1', '1', '1', '149086', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '104', '2024-12-12 12:12:10','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '8640',  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 ('8185','455', '0', '1', 'اضافة فاتورة مبيعات', '149086', '8640', '2024-12-12 12:12: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-12', 455, 590, 590
                    , 590, 590, 590, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+455, sellCostBuyPrice =sellCostBuyPrice+590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+590
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+590
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+590
                            , 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-12', 455, 590, 590
                    , 590, 590, 590, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+455, sellCostBuyPrice =sellCostBuyPrice+590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+590
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+590
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+590
                            , 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, 455, 590, 590
                    , 590, 590, 590, 590, 145, 145)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+455, netSellCostBuyPrice = netSellCostBuyPrice+590
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+590
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+590
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+590
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+590
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+590
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+145
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+145;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab6b873c2c and sellbillId = 149086 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

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-12 12:12:10', '0675ab6fad7a1a', '1', '0.00', '0', '0', '1', '400.00', '400', '400', '0', '1', '2024-12-12 12:13:47', '', '104', '0', 'نقدي', '1', '0', '3', '71', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149087', '0', '2024-12-12 12:13:47', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '400', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 12:12:10','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', '149087', '1', '15763', '1', '400', '400', '0', '', '1', '2024-12-12 12:13:47', '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 = 544762;
 INSERT INTO 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-12', 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-12', 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 = '14', userid = '104', storedetaildate = '2024-12-12 12:13:47' WHERE storedetailid = '15762';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15763', '1', '1', '1', '149087', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-12 12:13:47','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '9040',  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 ('8640','400', '0', '1', 'اضافة فاتورة مبيعات', '149087', '9040', '2024-12-12 12:13:47', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 71 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-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 400, 340, 340
                    , 340, 340, 340, 335, 340, 340)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+400, netSellCostBuyPrice = netSellCostBuyPrice+340
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+340
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+340
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+340
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+340
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+335
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+340
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+340;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab6fad7a1a and sellbillId = 149087 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:43:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:13:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:13: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-12 08:44:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:14:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 12:14:10', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:44:34";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 12:14:34", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:14: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 0675ab58816777
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7674,@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-12 12:06:00', '0675ab58816777', '7674', '0.00', '1253', '0', '1', '1253.00', '1253', '0', '1253', '1', '2024-12-12 12:14:34', '', '75', '0', 'امنية اسعد الغردقة E500', '2', '1', '3', '78', 'امنية اسعد الغردقة E500', '4' ,'0','','','','','-1','0','0','0','0','0','1253','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1253', userid = '75' WHERE clientid = '7674';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7674','0.00','1253','0','اضافة فاتورة مبيعات','149088', '1253', '2024-12-12 12:14:34', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1253', '0', null, '0', null, null,'', '0','1','1','1253','1','2024-12-12 12:06:00','0','0');
UPDATE client SET  inUse = 0 where clientid = 7674;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '149088', '14', '16204', '2', '610', '1220', '0', '', '1', '2024-12-12 12:14:34', '16204', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35973-2,','1','1','0','0','610','1220','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 = 544763;
 INSERT INTO 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-12', 1220, 1000, 1000
                    , 2210, 1000, 2210, 1000
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 1000, 3420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1220, sellCostBuyPrice =sellCostBuyPrice+1000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1000
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1000
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-12', 1220, 1000, 1000
                    , 2210, 1000, 2210, 1000
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1000, 3420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1220, sellCostBuyPrice =sellCostBuyPrice+1000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1000
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1000
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:14:34' WHERE storedetailid = '16203';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16204', '1', '2', '1', '149088', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-3', '-5', '75', '2024-12-12 12:14:34','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149088', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 12:14:34', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149088', '17', '10291', '1', '13', '13', '0', '', '1', '2024-12-12 12:14:34', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','13','13','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 78 where clientid = 7674;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1253, 1000, 1000
                    , 2210, 1000, 2210, 1000
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1000, 3420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1253, sellCostBuyPrice =sellCostBuyPrice+1000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1000
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1000
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7674, '2024-12-12', 1253, 1000, 1000
                    , 2210, 1000, 2210, 1000
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1000, 3420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1253, sellCostBuyPrice =sellCostBuyPrice+1000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2210
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2210
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1000
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1000
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3420
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1253, 1000, 1000
                    , 2210, 1000, 2210, 1000, 1000, 3420)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1253, netSellCostBuyPrice = netSellCostBuyPrice+1000
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1000
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2210
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1000
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2210
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1000
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1000
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+3420;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab58816777 and sellbillId = 149088 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ab78b71346
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3648,@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-12 12:14:35', '0675ab78b71346', '3648', '0.00', '2687', '0', '1', '2687.00', '2687', '0', '2687', '1', '2024-12-12 12:17:30', '', '75', '0', 'سالي مصطفي ', '2', '1', '3', '78', 'سالي مصطفي ', '8' ,'0','','','','','-1','0','0','0','0','0','2687','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2687', userid = '75' WHERE clientid = '3648';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3648','0.00','2687','0','اضافة فاتورة مبيعات','149089', '2687', '2024-12-12 12:17:30', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2687', '0', null, '0', null, null,'', '0','1','1','2687','1','2024-12-12 12:14:35','0','0');
UPDATE client SET  inUse = 0 where clientid = 3648;
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', '149089', '5', '16193', '1', '600', '600', '0', '', '0', '2024-12-12 12:17:30', '16193', '0.00', '-1', '1','0','','','0','0','0','0','0','0','0','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 = 544766;
 INSERT INTO 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-12', 600, 530, 530
                    , 530, 530, 530, 529.75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 530, 530, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+529.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+530
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+530
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 600, 530, 530
                    , 530, 530, 530, 529.75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 530, 530, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+529.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+530
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+530
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '16', userid = '75', storedetaildate = '2024-12-12 12:17:30' WHERE storedetailid = '16192';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16193', '1', '1', '1', '149089', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '75', '2024-12-12 12:17:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35697;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07112', '149089', '5', '16198', '1', '430', '430', '0', '', '0', '2024-12-12 12:17:31', '16198', '0.00', '-1', '1','0','','','0','0','0','0','0','0','0','0','','35697-1,','1','1','0','0','430','430','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 350, lastbuyprice_withDiscountAndTax = 350
                where sellbilldetailid = 544767;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16198, '2024-12-12', 430, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 430, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '15', userid = '75', storedetaildate = '2024-12-12 12:17:31' WHERE storedetailid = '16197';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16198', '1', '1', '1', '149089', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '75', '2024-12-12 12:17:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34630;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','79036', '149089', '5', '15705', '1', '230', '230', '0', '', '0', '2024-12-12 12:17:31', '15705', '0.00', '-1', '1','0','','','0','0','0','0','0','0','0','0','','34630-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 = 544768;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15705, '2024-12-12', 230, 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+230, 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-12', 230, 175, 175
                    , 175, 175, 175, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 175, 175, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, 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 = '6', userid = '75', storedetaildate = '2024-12-12 12:17:31' WHERE storedetailid = '15704';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15705', '1', '1', '1', '149089', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-12 12:17:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35580;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07082', '149089', '5', '16095', '1', '420', '420', '0', '', '0', '2024-12-12 12:17:31', '16095', '0.00', '-1', '1','0','','','0','0','0','0','0','0','0','0','','35580-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 365.00 , meanbuyprice = 364.00, lastbuyprice_withDiscount = 365.00, meanbuyprice_withDiscount = 364.00
        , lastbuyprice_withTax = 365, meanbuyprice_withTax = 363, lastbuyprice_withDiscountAndTax = 365
                where sellbilldetailid = 544769;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16095, '2024-12-12', 420, 365, 365
                    , 364, 365, 364, 362.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 365, 363, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+365
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+365, sellCostMeanBuyPrice = sellCostMeanBuyPrice+364
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+365, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+364
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+362.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+365
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+363
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 420, 365, 365
                    , 364, 365, 364, 362.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 365, 363, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+365
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+365, sellCostMeanBuyPrice = sellCostMeanBuyPrice+364
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+365, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+364
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+362.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+365
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+363
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:17:31' WHERE storedetailid = '16094';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16095', '1', '1', '1', '149089', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-12 12:17:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35597;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149089', '5', '15995', '2', '480', '960', '0', '', '0', '2024-12-12 12:17:31', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35597-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 = 544770;
 INSERT INTO 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-12', 960, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+960, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 960, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+960, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '113', userid = '75', storedetaildate = '2024-12-12 12:17:31' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '2', '1', '149089', 'اضافة فاتورة مبيعات', 'sellbillController.php', '115', '113', '75', '2024-12-12 12:17:31','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149089', '9', '2015', '1', '20', '20', '0', '', '0', '2024-12-12 12:17:31', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','0','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', '149089', '17', '10291', '1', '27', '27', '0', '', '0', '2024-12-12 12:17:31', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','0','0','','','1','1','0','0','27','27','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 78 where clientid = 3648;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 2687, 2260, 2260
                    , 2259, 2260, 2259, 2257.25
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2260, 2258, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2687, sellCostBuyPrice =sellCostBuyPrice+2260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2259
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2259
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2257.25
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2258
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (3648, '2024-12-12', 2687, 2260, 2260
                    , 2259, 2260, 2259, 2257.25
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2260, 2258, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2687, sellCostBuyPrice =sellCostBuyPrice+2260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2259
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2259
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2257.25
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2258
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2687, 2260, 2260
                    , 2259, 2260, 2259, 2257.25, 2260, 2258)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2687, netSellCostBuyPrice = netSellCostBuyPrice+2260
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2260
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2259
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2260
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2259
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2257.25
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2260
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2258;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab78b71346 and sellbillId = 149089 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

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-12 12:19:42', '0675ab8bead8ad', '10626', '0.00', '838', '0', '1', '838.00', '838', '0', '838', '1', '2024-12-12 12:21:21', '', '104', '0', 'هند محمد فريد', '1', '1', '3', '74', 'هند محمد فريد', '3' ,'0','','','','','-1','0','0','0','0','0','838','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '838', 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','838','0','اضافة فاتورة مبيعات','149090', '838', '2024-12-12 12:21:21', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '838', '0', null, '0', null, null,'', '0','1','1','838','1','2024-12-12 12:19:42','0','0');
UPDATE client SET  inUse = 0 where clientid = 10626;
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', '149090', '1', '16325', '1', '450', '450', '0', '', '1', '2024-12-12 12:21:21', '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 = 544773;
 INSERT INTO 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-12', 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-12', 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 = '40', userid = '104', storedetaildate = '2024-12-12 12:21:21' WHERE storedetailid = '16324';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16325', '1', '1', '1', '149090', 'اضافة فاتورة مبيعات', 'sellbillController.php', '41', '40', '104', '2024-12-12 12:21:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 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', '149090', '1', '16186', '1', '380', '380', '0', '', '1', '2024-12-12 12:21:22', '16186', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35938-1,','1','1','0','0','380','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 310.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 310.00
        , lastbuyprice_withTax = 310, meanbuyprice_withTax = 310, lastbuyprice_withDiscountAndTax = 310
                where sellbilldetailid = 544774;
 INSERT INTO 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-12', 380, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 380, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '28', userid = '104', storedetaildate = '2024-12-12 12:21:22' WHERE storedetailid = '16185';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16186', '1', '1', '1', '149090', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29', '28', '104', '2024-12-12 12:21: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 ('0','10291', '149090', '17', '10291', '1', '8', '8', '0', '', '1', '2024-12-12 12:21:22', '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 = 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-12', 838, 690, 690
                    , 690, 690, 690, 690
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,690, 690, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+838, sellCostBuyPrice =sellCostBuyPrice+690
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+690, sellCostMeanBuyPrice = sellCostMeanBuyPrice+690
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+690, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+690
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+690
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+690
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+690
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 838, 690, 690
                    , 690, 690, 690, 690
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,690, 690, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+838, sellCostBuyPrice =sellCostBuyPrice+690
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+690, sellCostMeanBuyPrice = sellCostMeanBuyPrice+690
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+690, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+690
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+690
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+690
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+690
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 838, 690, 690
                    , 690, 690, 690, 690, 690, 690)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+838, netSellCostBuyPrice = netSellCostBuyPrice+690
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+690
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+690
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+690
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+690
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+690
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+690
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+690;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab8bead8ad and sellbillId = 149090 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ab83c031b6
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1130,@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-12 12:17:32', '0675ab83c031b6', '1130', '9737.00', '12136', '0', '1', '2399.00', '2399', '0', '2399', '1', '2024-12-12 12:24:15', '', '75', '0', 'نضال عامر z271', '2', '1', '3', '98', 'نضال عامر z271', '18' ,'0','','','','','-1','0','0','0','0','0','2399','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '12136', userid = '75' WHERE clientid = '1130';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1130','9737.00','2399','0','اضافة فاتورة مبيعات','149091', '12136', '2024-12-12 12:24:15', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2399', '0', null, '0', null, null,'', '0','1','1','2399','1','2024-12-12 12:17:32','0','0');
UPDATE client SET  inUse = 0 where clientid = 1130;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31435;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','b1281', '149091', '2', '14052', '1', '100', '100', '0', '', '1', '2024-12-12 12:24:15', '14052', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31435-1,','1','1','0','0','100','100','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 = 544776;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14052, '2024-12-12', 100, 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+100, 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-12', 100, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-12 12:24:15' WHERE storedetailid = '14051';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14052', '1', '1', '1', '149091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-12 12:24:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33951;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2965', '149091', '1', '14549', '1', '165', '165', '0', '', '1', '2024-12-12 12:24:15', '14549', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33951-1,','1','1','0','0','165','165','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 197.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 197.00
        
                where sellbilldetailid = 544777;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14549, '2024-12-12', 165, 200, 200
                    , 197, 200, 197, 193.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+197
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+197
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+193.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-12', 165, 200, 200
                    , 197, 200, 197, 193.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+197
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+197
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+193.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 = '9', userid = '75', storedetaildate = '2024-12-12 12:24:15' WHERE storedetailid = '14548';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14549', '1', '1', '1', '149091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-12 12:24:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 31706;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('160','R2816', '149091', '1', '14039', '2', '130', '260', '0', '', '1', '2024-12-12 12:24:15', '14039', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31706-2,','1','1','0','0','130','260','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
        
                where sellbilldetailid = 544778;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14039, '2024-12-12', 260, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, 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+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-12', 260, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+320
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '75', storedetaildate = '2024-12-12 12:24:15' WHERE storedetailid = '14038';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14039', '1', '2', '1', '149091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '1', '75', '2024-12-12 12:24:15','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('160','R2821', '149091', '1', '14070', '1', '125', '125', '0', '', '1', '2024-12-12 12:24:16', '14070', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','125','125','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
        
                where sellbilldetailid = 544779;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14070, '2024-12-12', 125, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 125, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-12 12:24:16' WHERE storedetailid = '14069';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14070', '1', '1', '1', '149091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-12 12:24:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 32058;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2844', '149091', '1', '14179', '2', '235', '470', '0', '', '1', '2024-12-12 12:24:16', '14179', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32058-2,','1','1','0','0','235','470','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 286.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 286.00
        
                where sellbilldetailid = 544780;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14179, '2024-12-12', 470, 520, 520
                    , 572, 520, 572, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+572
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+572
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+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-12', 470, 520, 520
                    , 572, 520, 572, 520
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+572
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+572
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+520
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '75', storedetaildate = '2024-12-12 12:24:16' WHERE storedetailid = '14178';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14179', '1', '2', '1', '149091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '14', '75', '2024-12-12 12:24:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 32331;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('75','R2843', '149091', '1', '14188', '2', '80', '160', '0', '', '1', '2024-12-12 12:24:16', '14188', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32331-2,','1','1','0','0','80','160','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 75.00 , meanbuyprice = 75.00, lastbuyprice_withDiscount = 75.00, meanbuyprice_withDiscount = 75.00
        
                where sellbilldetailid = 544781;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14188, '2024-12-12', 160, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+160, 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+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-12', 160, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+160, 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-12 12:24:16' WHERE storedetailid = '14187';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14188', '1', '2', '1', '149091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '1', '75', '2024-12-12 12:24: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 ('130','R2540', '149091', '1', '12351', '2', '100', '200', '0', '', '1', '2024-12-12 12:24:16', '12351', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','100','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 130.00 , meanbuyprice = 144.00, lastbuyprice_withDiscount = 130.00, meanbuyprice_withDiscount = 144.00
        
                where sellbilldetailid = 544782;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12351, '2024-12-12', 200, 260, 260
                    , 288, 260, 288, 288.58
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+288
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+288
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+288.58
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-12', 200, 260, 260
                    , 288, 260, 288, 288.58
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+288
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+288
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+288.58
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:24:16' WHERE storedetailid = '12350';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12351', '1', '2', '1', '149091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-4', '-6', '75', '2024-12-12 12:24:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31745;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','R2818', '149091', '1', '14049', '1', '170', '170', '0', '', '1', '2024-12-12 12:24:16', '14049', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31745-1,','1','1','0','0','170','170','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 557.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 557.00
        
                where sellbilldetailid = 544783;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14049, '2024-12-12', 170, 240, 240
                    , 557, 240, 557, 237.22
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+557
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+557
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.22
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 170, 240, 240
                    , 557, 240, 557, 237.22
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+557
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+557
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.22
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '75', storedetaildate = '2024-12-12 12:24:16' WHERE storedetailid = '14048';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14049', '1', '1', '1', '149091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 12:24: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 ('220','R2836', '149091', '1', '14218', '2', '140', '280', '0', '', '1', '2024-12-12 12:24:16', '14218', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','140','280','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 241.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 241.00
        
                where sellbilldetailid = 544784;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14218, '2024-12-12', 280, 440, 440
                    , 482, 440, 482, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+482
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+482
                            , 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-12', 280, 440, 440
                    , 482, 440, 482, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+482
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+482
                            , 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 = '3', userid = '75', storedetaildate = '2024-12-12 12:24:16' WHERE storedetailid = '14217';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14218', '1', '2', '1', '149091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '3', '75', '2024-12-12 12:24: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 ('165','R2892', '149091', '1', '14329', '2', '135', '270', '0', '', '1', '2024-12-12 12:24:16', '14329', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','135','270','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 163.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 163.00
        
                where sellbilldetailid = 544785;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14329, '2024-12-12', 270, 330, 330
                    , 326, 330, 326, 321.82
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+326
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+326
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+321.82
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-12', 270, 330, 330
                    , 326, 330, 326, 321.82
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+326
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+326
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+321.82
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:24:16' WHERE storedetailid = '14328';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14329', '1', '2', '1', '149091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '0', '75', '2024-12-12 12:24:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31553;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2847', '149091', '1', '14178', '1', '175', '175', '0', '', '1', '2024-12-12 12:24:16', '14178', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31553-1,','1','1','0','0','175','175','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 = 544786;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14178, '2024-12-12', 175, 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+175, 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-12', 175, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+175, 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 = '1', userid = '75', storedetaildate = '2024-12-12 12:24:16' WHERE storedetailid = '14177';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14178', '1', '1', '1', '149091', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-12 12:24:16','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149091', '17', '10291', '1', '24', '24', '0', '', '1', '2024-12-12 12:24:16', '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 = 98 where clientid = 1130;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 2399, 3050, 3050
                    , 3482, 3050, 3482, 3060.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2399, sellCostBuyPrice =sellCostBuyPrice+3050
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3050, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3482
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3050, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3482
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3060.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1130, '2024-12-12', 2399, 3050, 3050
                    , 3482, 3050, 3482, 3060.95
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2399, sellCostBuyPrice =sellCostBuyPrice+3050
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3050, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3482
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3050, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3482
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3060.95
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2399, 3050, 3050
                    , 3482, 3050, 3482, 3060.95, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2399, netSellCostBuyPrice = netSellCostBuyPrice+3050
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3050
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+3482
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3050
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+3482
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+3060.95
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab83c031b6 and sellbillId = 149091 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:54:17";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 12:24:17", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:24:17', '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-12 08:55:25";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:25:25", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:25:25', '2', 'showDetail', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=143271');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:55:27";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:25:27", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:25:27', '2', 'showDetail', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=137217');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:57:16";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:27:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:27: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 0675ab922ce8a9
-- ----------------------------------------------------------------------------------------------------

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-12 12:21:22', '0675ab922ce8a9', '1', '0.00', '0', '0', '1', '800.00', '800', '800', '0', '1', '2024-12-12 12:27:16', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'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-12','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','اضافة فاتورة مبيعات','149092', '0', '2024-12-12 12:27:16', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '800', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 12:21:22','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36006;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('650','H1601', '149092', '14', '16226', '1', '800', '800', '0', '', '1', '2024-12-12 12:27:16', '16226', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36006-1,','1','1','0','0','800','800','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 650.00 , meanbuyprice = 650.00, lastbuyprice_withDiscount = 650.00, meanbuyprice_withDiscount = 650.00
        , lastbuyprice_withTax = 650, meanbuyprice_withTax = 650, lastbuyprice_withDiscountAndTax = 650
                where sellbilldetailid = 544788;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16226, '2024-12-12', 800, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 650, 650, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+650
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 800, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0, 650, 650, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+650
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '104', storedetaildate = '2024-12-12 12:27:16' WHERE storedetailid = '16225';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16226', '1', '1', '1', '149092', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-12 12:27:16','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '9840',  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 ('9040','800', '0', '1', 'اضافة فاتورة مبيعات', '149092', '9840', '2024-12-12 12:27:16', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 74 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 800, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,650, 650, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+650
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 800, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,650, 650, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+800, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+650
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+650
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 800, 650, 650
                    , 650, 650, 650, 650, 650, 650)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+800, netSellCostBuyPrice = netSellCostBuyPrice+650
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+650
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+650
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+650
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+650
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+650
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+650
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+650;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab922ce8a9 and sellbillId = 149092 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 08:57:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:27:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:27: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-12 09:01:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:31:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:31: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-12 09:02:04";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:32:04", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:32:04', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675abb7a67e7f
-- ----------------------------------------------------------------------------------------------------

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-12 12:31:22', '0675abb7a67e7f', '1', '0.00', '0', '0', '1', '-340.00', '-340', '-340', '0', '1', '2024-12-12 12:32:04', '', '104', '0', 'نقدي', '1', '0', '4', '0', '470', '810', 'نقدي', '1', '2', '0', '', '', '','','-1','0','0','0','','0','-340','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','اضافة فاتورة مبيعات ومردودات','85', '0', '2024-12-12 12:32:04', '104', 'sellbillandruternController.php', 'اضافة فاتورة مبيعات ومردودات', '340', '0', null, '0', null, null,'', '0','1','1','-0','1','2024-12-12 12:31:22','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35777;
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 ('380','H1551', '85', '14', '16035', '1', '470', '470.00', '0', '', '0', '2024-12-12 12:32:04', '0', '16035', '0.00', '-1', '1','0','','','0','0','0','0','0','0','35777-1,','1','1','','0','0','470','470','0','','','0');
UPDATE sellandruternbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 382.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 382.00
        , lastbuyprice_withTax = 380, meanbuyprice_withTax = 384, lastbuyprice_withDiscountAndTax = 380
                where sellbilldetailid = 220;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16035, '2024-12-12', 470, 380, 380
                    , 382, 380, 382, 386.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 380, 384, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+382
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+382
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+386.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+384
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 470, 380, 380
                    , 382, 380, 382, 386.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 380, 384, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+382
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+382
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+386.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+384
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '104', storedetaildate = '2024-12-12 12:32:04' WHERE storedetailid = '16034';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16035', '1', '1', '1', '85', 'فاتوره مبيعات ومردودات', 'sellbillandruternController.php', '3', '2', '104', '2024-12-12 12:32:04','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 ('495.00','H1503', '85', '14', '15941', '1', '580', '580', '0', '', '0', '2024-12-12 12:32:04', '1', '15941', '0.00', '-1', '1','0','','','0','0','0','0','0','0','','1','1','','0','0','580','580','0','','','0');
UPDATE sellandruternbilldetail 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 = 221;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15941, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 580, 495, 495, 495
                    , 495, 495, 495, 0, 1, 0, 0, 495, 495)
                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+580, returnSellCostBuyPrice = returnSellCostBuyPrice+495, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+495
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+495, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+495
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+495
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+495
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+495
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+495
                        , 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 580, 495, 495, 495
                    , 495, 495, 495, 0, 0, 495, 495)
                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+580, returnSellCostBuyPrice = returnSellCostBuyPrice+495, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+495
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+495, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+495
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+495
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+495
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+495
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+495;
UPDATE storedetail SET  productquantity = '-4', userid = '104', storedetaildate = '2024-12-12 12:32:04' WHERE storedetailid = '15940';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15941', '1', '1', '0', '85', 'اضافة فاتورة مردودات مبيعات', 'sellbillandruternController.php', '-5', '-4', '104', '2024-12-12 12:32:04','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 ('170.00','07019', '85', '5', '15985', '1', '230', '230', '0', '', '0', '2024-12-12 12:32:04', '1', '15985', '0.00', '-1', '1','0','','','0','0','0','0','0','0','','1','1','','0','0','230','230','0','','','0');
UPDATE sellandruternbilldetail 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 = 222;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15985, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 230, 170, 170, 170
                    , 170, 170, 170, 0, 1, 0, 0, 170, 170)
                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+170, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+170
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+170, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+170
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+170
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+170
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+170
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+170
                        , 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 230, 170, 170, 170
                    , 170, 170, 170, 0, 0, 170, 170)
                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+170, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+170
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+170, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+170
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+170
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+170
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+170
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+170;
UPDATE storedetail SET  productquantity = '0', userid = '104', storedetaildate = '2024-12-12 12:32:04' WHERE storedetailid = '15984';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15985', '1', '1', '0', '85', 'اضافة فاتورة مردودات مبيعات', 'sellbillandruternController.php', '-1', '0', '104', '2024-12-12 12:32:04','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '9500',  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 ('9840','340', '1', '1', 'اضافة فاتورة مبيعات ومردودات', '85', '9500', '2024-12-12 12:32:04', '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-12', 470, 380, 380
                    , 382, 380, 382, 386.67
                    , 810, 665, 665, 665
                    , 665, 665, 665 ,380, 384, 665, 665)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+382
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+382
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+386.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+384
                        , returnSellVal = returnSellVal+810, returnSellCostBuyPrice = returnSellCostBuyPrice+665, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+665
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+665, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+665
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+665
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+665
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+665
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+665;
 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-12', 470, 380, 380
                    , 382, 380, 382, 386.67
                    , 810, 665, 665, 665
                    , 665, 665, 665 ,380, 384, 665, 665)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+382
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+382
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+386.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+384
                        , returnSellVal = returnSellVal+810, returnSellCostBuyPrice = returnSellCostBuyPrice+665, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+665
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+665, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+665
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+665
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+665
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+665
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+665;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -340, -285, -285
                    , -283, -285, -283, -278.33, -285, -281)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-340, netSellCostBuyPrice = netSellCostBuyPrice+-285
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-285
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-283
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-285
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-283
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-278.33
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-285
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-281;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675abb7a67e7f and sellbillId = 85 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:02:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:32:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillandruternController.php', '2024-12-12 12:32:05', '104', 'editprint', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillandruternController.php?do=editprint&id=85');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:03:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:33:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:33: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-12 09:04:10";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:34:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 12:34:10', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:04:12";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:34:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 12:34:12', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:04:13";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:34:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 12:34:13', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:04:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:34:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:34: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 0675abc130e364
-- ----------------------------------------------------------------------------------------------------

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-12 12:33:55', '0675abc130e364', '1', '0.00', '0', '0', '1', '800.00', '800', '800', '0', '1', '2024-12-12 12:34:20', '', '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-12','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','اضافة فاتورة مبيعات','149093', '0', '2024-12-12 12:34:21', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '800', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 12:33:55','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35880;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149093', '5', '16279', '2', '400', '800', '0', '', '1', '2024-12-12 12:34:21', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35880-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 = 544789;
 INSERT INTO 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-12', 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-12', 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 = '57', userid = '104', storedetaildate = '2024-12-12 12:34: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', '149093', 'اضافة فاتورة مبيعات', 'sellbillController.php', '59', '57', '104', '2024-12-12 12:34:21','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '10300',  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 ('9500','800', '0', '1', 'اضافة فاتورة مبيعات', '149093', '10300', '2024-12-12 12:34:21', '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-12', 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-12', 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 0675abc130e364 and sellbillId = 149093 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =481
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(481,@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 ('481','-618.00','618','0','تسوية عجز عميل بالزيادة','-1', '0', '2024-12-12 12:34:44', '2', 'clientDeficitController.php', '', '618', '0', null, '0', null, null,'', '0','1','1','618','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12', userid = '2' WHERE clientid = '481';
UPDATE client SET  inUse = 0 where clientid = 481;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =481 ,id=245713
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:04:45";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:34:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 12:34:45', '2', 'sucess', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:04:46";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:34:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 12:34:46', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:04:50";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:34:50", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 12:34:50', '2', 'add', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =3300
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3300,@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 ('3300','-229.00','229','0','تسوية عجز عميل بالزيادة','-1', '0', '2024-12-12 12:34:50', '2', 'clientDeficitController.php', '', '229', '0', null, '0', null, null,'', '0','1','1','229','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12', userid = '2' WHERE clientid = '3300';
UPDATE client SET  inUse = 0 where clientid = 3300;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =3300 ,id=245714
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:04:51";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:34:51", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 12:34:51', '2', 'sucess', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:04:52";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:34:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 12:34:53', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:04:56";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:34:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 12:34:56', '2', 'add', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =2227
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2227,@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 ('2227','-200.00','200','0','تسوية عجز عميل بالزيادة','-1', '0', '2024-12-12 12:34:56', '2', 'clientDeficitController.php', '', '200', '0', null, '0', null, null,'', '0','1','1','200','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12', userid = '2' WHERE clientid = '2227';
UPDATE client SET  inUse = 0 where clientid = 2227;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =2227 ,id=245715
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:04:56";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:34:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 12:34:56', '2', 'sucess', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:04:58";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:34:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 12:34:58', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:08:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:38:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:38:56', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675abc2dd6714
-- ----------------------------------------------------------------------------------------------------

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-12 12:34:21', '0675abc2dd6714', '1', '0.00', '0', '0', '1', '1300.00', '1300', '1300', '0', '1', '2024-12-12 12:38:56', '', '104', '0', 'نقدي', '1', '0', '3', '92', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1300','0','','0','0','1300','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149094', '0', '2024-12-12 12:38:56', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 12:34:21','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', '149094', '1', '15319', '1', '330', '330', '0', '', '1', '2024-12-12 12:38:56', '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 = 544790;
 INSERT INTO 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-12', 330, 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+330, 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-12', 330, 285, 285
                    , 285, 285, 285, 283.75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 285, 178, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, 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 = '-29', userid = '104', storedetaildate = '2024-12-12 12:38:56' WHERE storedetailid = '15318';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15319', '1', '1', '1', '149094', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-28', '-29', '104', '2024-12-12 12:38:56','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0K795', '149094', '7', '15877', '1', '490', '490', '0', '', '1', '2024-12-12 12:38:56', '15877', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','490','490','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 = 544791;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15877, '2024-12-12', 490, 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+490, 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-12', 490, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0, 490, 490, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, 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 = '-1', userid = '104', storedetaildate = '2024-12-12 12:38:56' WHERE storedetailid = '15876';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15877', '1', '1', '1', '149094', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '104', '2024-12-12 12:38:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35597;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149094', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-12 12:38:56', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35597-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 = 544792;
 INSERT INTO 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-12', 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-12', 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 = '112', userid = '104', storedetaildate = '2024-12-12 12:38:56' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '149094', 'اضافة فاتورة مبيعات', 'sellbillController.php', '113', '112', '104', '2024-12-12 12:38:56','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '11600',  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 ('10300','1300', '0', '1', 'اضافة فاتورة مبيعات', '149094', '11600', '2024-12-12 12:38:56', '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-12', 1300, 1195, 1195
                    , 1195, 1195, 1195, 1193.75
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1195, 1088, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1300, sellCostBuyPrice =sellCostBuyPrice+1195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1195
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1193.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1195
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1088
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 1300, 1195, 1195
                    , 1195, 1195, 1195, 1193.75
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1195, 1088, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1300, sellCostBuyPrice =sellCostBuyPrice+1195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1195
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1193.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1195
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1088
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1300, 1195, 1195
                    , 1195, 1195, 1195, 1193.75, 1195, 1088)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1300, netSellCostBuyPrice = netSellCostBuyPrice+1195
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1195
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1195
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1195
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1195
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1193.75
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1195
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1088;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675abc2dd6714 and sellbillId = 149094 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:08:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:38:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:38: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-12 09:13:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:43:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:43: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 0675abd419743b
-- ----------------------------------------------------------------------------------------------------

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-12 12:38:57', '0675abd419743b', '1', '0.00', '0', '0', '1', '820.00', '820', '820', '0', '1', '2024-12-12 12:43:15', '', '104', '0', 'نقدي', '1', '0', '3', '21', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','820','0','','0','0','820','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149095', '0', '2024-12-12 12:43:15', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '820', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 12:38:57','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35881;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('535','H1625', '149095', '14', '16280', '1', '635', '635', '0', '', '1', '2024-12-12 12:43:15', '16280', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35881-1,','1','1','0','0','635','635','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 545.00 , meanbuyprice = 543.00, lastbuyprice_withDiscount = 545.00, meanbuyprice_withDiscount = 543.00
        , lastbuyprice_withTax = 545, meanbuyprice_withTax = 449, lastbuyprice_withDiscountAndTax = 545
                where sellbilldetailid = 544793;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16280, '2024-12-12', 635, 545, 545
                    , 543, 545, 543, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 545, 449, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+635, sellCostBuyPrice =sellCostBuyPrice+545
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+545, sellCostMeanBuyPrice = sellCostMeanBuyPrice+543
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+545, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+543
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+449
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 635, 545, 545
                    , 543, 545, 543, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 545, 449, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+635, sellCostBuyPrice =sellCostBuyPrice+545
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+545, sellCostMeanBuyPrice = sellCostMeanBuyPrice+543
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+545, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+543
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+449
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '22', userid = '104', storedetaildate = '2024-12-12 12:43:15' WHERE storedetailid = '16279';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16280', '1', '1', '1', '149095', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '104', '2024-12-12 12:43:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31097;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2801', '149095', '1', '13987', '1', '185', '185', '0', '', '1', '2024-12-12 12:43:15', '13987', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31097-1,','1','1','0','0','185','185','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 260.00
        
                where sellbilldetailid = 544794;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13987, '2024-12-12', 185, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 185, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-12 12:43:15' WHERE storedetailid = '13986';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13987', '1', '1', '1', '149095', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-12 12:43:15','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '12420',  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 ('11600','820', '0', '1', 'اضافة فاتورة مبيعات', '149095', '12420', '2024-12-12 12:43:15', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 21 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 820, 805, 805
                    , 803, 805, 803, 800
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,545, 449, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+820, sellCostBuyPrice =sellCostBuyPrice+805
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+805, sellCostMeanBuyPrice = sellCostMeanBuyPrice+803
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+805, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+803
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+800
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+449
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 820, 805, 805
                    , 803, 805, 803, 800
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,545, 449, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+820, sellCostBuyPrice =sellCostBuyPrice+805
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+805, sellCostMeanBuyPrice = sellCostMeanBuyPrice+803
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+805, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+803
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+800
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+449
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 820, 805, 805
                    , 803, 805, 803, 800, 545, 449)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+820, netSellCostBuyPrice = netSellCostBuyPrice+805
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+805
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+803
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+805
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+803
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+800
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+545
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+449;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675abd419743b and sellbillId = 149095 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ab7a56b2db
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(65,@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-12 12:15:01', '0675ab7a56b2db', '65', '0.00', '566', '0', '1', '566.00', '566', '0', '566', '1', '2024-12-12 12:45:52', '', '75', '0', 'ام عمر ', '2', '1', '3', '98', 'ام عمر ', '4' ,'0','','','','','-1','0','0','0','0','0','566','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '566', userid = '75' WHERE clientid = '65';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('65','0.00','566','0','اضافة فاتورة مبيعات','149096', '566', '2024-12-12 12:45:52', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '566', '0', null, '0', null, null,'', '0','1','1','566','1','2024-12-12 12:15:01','0','0');
UPDATE client SET  inUse = 0 where clientid = 65;
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', '149096', '5', '16245', '1', '300', '300', '0', '', '1', '2024-12-12 12:45: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 = 544795;
 INSERT INTO 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-12', 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-12', 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 = '25', userid = '75', storedetaildate = '2024-12-12 12:45: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', '149096', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '75', '2024-12-12 12:45:52','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35593;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149096', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-12 12:45:52', '15850', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35593-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 = 544796;
 INSERT INTO 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-12', 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-12', 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 = '66', userid = '75', storedetaildate = '2024-12-12 12:45: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', '149096', 'اضافة فاتورة مبيعات', 'sellbillController.php', '67', '66', '75', '2024-12-12 12:45: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', '149096', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 12:45: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', '149096', '17', '10291', '1', '6', '6', '0', '', '1', '2024-12-12 12:45:52', '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 = 98 where clientid = 65;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 566, 430, 430
                    , 430, 430, 430, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,430, 428, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+566, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+430
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+430
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+428
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (65, '2024-12-12', 566, 430, 430
                    , 430, 430, 430, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,430, 428, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+566, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+430
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+430
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+428
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 566, 430, 430
                    , 430, 430, 430, 430, 430, 428)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+566, netSellCostBuyPrice = netSellCostBuyPrice+430
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+430
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+430
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+430
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+430
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+430
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+430
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+428;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab7a56b2db and sellbillId = 149096 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:15:53";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 12:45:53", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:45:53', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:16:09";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 12:46:09", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:46: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 0675ab9d1481d8
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2540,@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-12 12:24:17', '0675ab9d1481d8', '2540', '7.00', '1891', '0', '1', '1884.00', '1884', '0', '1884', '1', '2024-12-12 12:46:09', '', '75', '0', 'مريم بخيت z425', '2', '1', '3', '98', 'مريم بخيت z425', '6' ,'0','','','','','-1','0','0','0','0','0','1884','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1891', userid = '75' WHERE clientid = '2540';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2540','7.00','1884','0','اضافة فاتورة مبيعات','149097', '1891', '2024-12-12 12:46:09', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1884', '0', null, '0', null, null,'', '0','1','1','1884','1','2024-12-12 12:24:17','0','0');
UPDATE client SET  inUse = 0 where clientid = 2540;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35345;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('195','07007', '149097', '5', '15954', '1', '245', '245', '0', '', '1', '2024-12-12 12:46:09', '15954', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35345-1,','1','1','0','0','245','245','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 194.00, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 194.00
        , lastbuyprice_withTax = 195, meanbuyprice_withTax = 193, lastbuyprice_withDiscountAndTax = 195
                where sellbilldetailid = 544799;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15954, '2024-12-12', 245, 195, 195
                    , 194, 195, 194, 192.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 195, 193, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+245, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+194
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+194
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+192.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+195
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+193
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 245, 195, 195
                    , 194, 195, 194, 192.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 195, 193, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+245, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+194
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+194
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+192.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+195
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+193
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:46:09' WHERE storedetailid = '15953';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15954', '1', '1', '1', '149097', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-12 12:46:09','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', '149097', '5', '16266', '1', '210', '210', '0', '', '1', '2024-12-12 12:46:09', '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 = 544800;
 INSERT INTO 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-12', 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-12', 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 = '15', userid = '75', storedetaildate = '2024-12-12 12:46:09' WHERE storedetailid = '16265';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16266', '1', '1', '1', '149097', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '75', '2024-12-12 12:46:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34460;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06825', '149097', '5', '15537', '1', '110', '110', '0', '', '1', '2024-12-12 12:46:09', '15537', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34460-1,','1','1','0','0','110','110','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 163.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 163.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 103, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 544801;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15537, '2024-12-12', 110, 165, 165
                    , 163, 165, 163, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 103, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+110, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+163
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+163
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+103
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 110, 165, 165
                    , 163, 165, 163, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 103, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+110, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+163
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+163
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+103
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:46:09' WHERE storedetailid = '15536';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15537', '1', '1', '1', '149097', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-12 12:46: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 ('460','H1456', '149097', '14', '15836', '1', '550', '550', '0', '', '1', '2024-12-12 12:46:09', '15836', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','550','550','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 460.00 , meanbuyprice = 464.00, lastbuyprice_withDiscount = 460.00, meanbuyprice_withDiscount = 464.00
        , lastbuyprice_withTax = 460, meanbuyprice_withTax = 467, lastbuyprice_withDiscountAndTax = 460
                where sellbilldetailid = 544802;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15836, '2024-12-12', 550, 460, 460
                    , 464, 460, 464, 465
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 460, 467, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+464
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+464
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+465
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+460
                            , 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
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 550, 460, 460
                    , 464, 460, 464, 465
                    , 0, 0, 0, 0
                    , 0, 0, 0, 460, 467, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+464
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+464
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+465
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+460
                            , 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;
UPDATE storedetail SET  productquantity = '-4', userid = '75', storedetaildate = '2024-12-12 12:46:09' WHERE storedetailid = '15835';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15836', '1', '1', '1', '149097', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-3', '-4', '75', '2024-12-12 12:46:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35757;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('630','H1593', '149097', '14', '16227', '1', '750', '750', '0', '', '1', '2024-12-12 12:46:09', '16227', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35757-1,','1','1','0','0','750','750','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 630.00 , meanbuyprice = 630.00, lastbuyprice_withDiscount = 630.00, meanbuyprice_withDiscount = 630.00
        , lastbuyprice_withTax = 630, meanbuyprice_withTax = 630, lastbuyprice_withDiscountAndTax = 630
                where sellbilldetailid = 544803;
 INSERT INTO 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-12', 750, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+630
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 750, 630, 630
                    , 630, 630, 630, 630
                    , 0, 0, 0, 0
                    , 0, 0, 0, 630, 630, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+630
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+630, sellCostMeanBuyPrice = sellCostMeanBuyPrice+630
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+630, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+630
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+630
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+630
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+630
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-12 12:46:09' WHERE storedetailid = '16226';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16227', '1', '1', '1', '149097', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-12 12:46: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', '149097', '17', '10291', '1', '19', '19', '0', '', '1', '2024-12-12 12:46:09', '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 = 98 where clientid = 2540;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1884, 1605, 1605
                    , 1606, 1605, 1606, 1602.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1605, 1548, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1884, sellCostBuyPrice =sellCostBuyPrice+1605
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1605, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1606
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1605, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1606
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1602.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1605
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1548
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2540, '2024-12-12', 1884, 1605, 1605
                    , 1606, 1605, 1606, 1602.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1605, 1548, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1884, sellCostBuyPrice =sellCostBuyPrice+1605
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1605, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1606
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1605, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1606
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1602.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1605
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1548
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1884, 1605, 1605
                    , 1606, 1605, 1606, 1602.5, 1605, 1548)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1884, netSellCostBuyPrice = netSellCostBuyPrice+1605
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1605
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1606
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1605
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1606
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1602.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1605
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1548;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ab9d1481d8 and sellbillId = 149097 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675abef2522a1
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4051,@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-12 12:46:10', '0675abef2522a1', '4051', '0.00', '970', '0', '1', '970.00', '970', '0', '970', '1', '2024-12-12 12:48:51', '', '75', '0', 'مروة العربي 41', '2', '1', '3', '87', 'مروة العربي 41', '6' ,'0','','','','','-1','0','0','0','0','0','970','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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 = '4051';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4051','0.00','970','0','اضافة فاتورة مبيعات','149098', '970', '2024-12-12 12:48:51', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '970', '0', null, '0', null, null,'', '0','1','1','970','1','2024-12-12 12:46:10','0','0');
UPDATE client SET  inUse = 0 where clientid = 4051;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35552;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','15980', '149098', '5', '15980', '1', '310', '310', '0', '', '1', '2024-12-12 12:48:51', '15980', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35552-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 = 544805;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15980, '2024-12-12', 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-12', 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 = '18', userid = '75', storedetaildate = '2024-12-12 12:48:51' WHERE storedetailid = '15979';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15980', '1', '1', '1', '149098', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '75', '2024-12-12 12:48:51','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', '149098', '1', '15356', '1', '210', '210', '0', '', '1', '2024-12-12 12:48:51', '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 = 544806;
 INSERT INTO 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-12', 210, 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+210, 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-12', 210, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:48:51' WHERE storedetailid = '15355';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15356', '1', '1', '1', '149098', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 12:48:51','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('155','07044', '149098', '5', '16023', '1', '200', '200', '0', '', '1', '2024-12-12 12:48:51', '16023', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 155.00 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155.00, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where sellbilldetailid = 544807;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16023, '2024-12-12', 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-12', 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 = '-3', userid = '75', storedetaildate = '2024-12-12 12:48:51' WHERE storedetailid = '16022';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16023', '1', '1', '1', '149098', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-2', '-3', '75', '2024-12-12 12:48:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34427;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06839', '149098', '5', '15567', '1', '220', '220', '0', '', '1', '2024-12-12 12:48:51', '15567', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34427-1,','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 175.00 , meanbuyprice = 172.00, lastbuyprice_withDiscount = 175.00, meanbuyprice_withDiscount = 172.00
        , lastbuyprice_withTax = 175, meanbuyprice_withTax = 73, lastbuyprice_withDiscountAndTax = 175
                where sellbilldetailid = 544808;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15567, '2024-12-12', 220, 175, 175
                    , 172, 175, 172, 171.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 175, 73, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+172
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+172
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+171.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+175
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+73
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 220, 175, 175
                    , 172, 175, 172, 171.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 175, 73, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+172
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+172
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+171.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+175
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+73
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '75', storedetaildate = '2024-12-12 12:48:51' WHERE storedetailid = '15566';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15567', '1', '1', '1', '149098', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-12 12:48:51','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149098', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 12:48:51', '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', '149098', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-12 12:48:51', '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 = 87 where clientid = 4051;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 970, 730, 730
                    , 727, 730, 727, 726.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,580, 478, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+970, sellCostBuyPrice =sellCostBuyPrice+730
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+730, sellCostMeanBuyPrice = sellCostMeanBuyPrice+727
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+730, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+727
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+726.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4051, '2024-12-12', 970, 730, 730
                    , 727, 730, 727, 726.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,580, 478, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+970, sellCostBuyPrice =sellCostBuyPrice+730
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+730, sellCostMeanBuyPrice = sellCostMeanBuyPrice+727
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+730, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+727
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+726.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+580
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 970, 730, 730
                    , 727, 730, 727, 726.67, 580, 478)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+970, netSellCostBuyPrice = netSellCostBuyPrice+730
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+730
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+727
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+730
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+727
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+726.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+580
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+478;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675abef2522a1 and sellbillId = 149098 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:18:52";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 12:48:52", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:48:52', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:20:15";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 12:50:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:50:15', '2', 'showDetail', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149041');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:20:21";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 12:50:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 12:50:21', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:20:31";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 12:50:31", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:50:31', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675abf94a7818
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9650,@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-12 12:48:52', '0675abf94a7818', '9650', '-135.00', '37', '0', '1', '172.00', '172', '0', '172', '1', '2024-12-12 12:50:31', '', '75', '0', 'جهاد 41', '2', '1', '3', '87', 'جهاد 41', '3' ,'0','','','','','-1','0','0','0','0','0','172','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '37', userid = '75' WHERE clientid = '9650';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9650','-135.00','172','0','اضافة فاتورة مبيعات','149099', '37', '2024-12-12 12:50:31', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '172', '0', null, '0', null, null,'', '0','1','1','172','1','2024-12-12 12:48:52','0','0');
UPDATE client SET  inUse = 0 where clientid = 9650;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31601;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('100','06249', '149099', '5', '14210', '1', '150', '150', '0', '', '1', '2024-12-12 12:50:32', '14210', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31601-1,','1','1','0','0','150','150','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 100.00 , meanbuyprice = 100.00, lastbuyprice_withDiscount = 100.00, meanbuyprice_withDiscount = 100.00
        
                where sellbilldetailid = 544811;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14210, '2024-12-12', 150, 100, 100
                    , 100, 100, 100, 100
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+100
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+100
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+100
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 150, 100, 100
                    , 100, 100, 100, 100
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+100
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+100
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+100
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:50:32' WHERE storedetailid = '14209';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14210', '1', '1', '1', '149099', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-12 12:50: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', '149099', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 12:50: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', '149099', '17', '10291', '1', '2', '2', '0', '', '1', '2024-12-12 12:50:32', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','2','2','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 87 where clientid = 9650;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 172, 100, 100
                    , 100, 100, 100, 100
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+172, sellCostBuyPrice =sellCostBuyPrice+100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+100
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+100
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+100
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9650, '2024-12-12', 172, 100, 100
                    , 100, 100, 100, 100
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+172, sellCostBuyPrice =sellCostBuyPrice+100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+100
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+100
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+100
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 172, 100, 100
                    , 100, 100, 100, 100, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+172, netSellCostBuyPrice = netSellCostBuyPrice+100
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+100
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+100
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+100
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+100
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+100
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675abf94a7818 and sellbillId = 149099 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675abff8cf1bb
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8939,@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-12 12:50:32', '0675abff8cf1bb', '8939', '0.00', '980', '0', '1', '980.00', '980', '0', '980', '1', '2024-12-12 12:52:59', '', '75', '0', 'برباره عطيه d544', '2', '1', '3', '81', 'برباره عطيه d544', '6' ,'0','','','','','-1','0','0','0','0','0','980','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '980', userid = '75' WHERE clientid = '8939';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8939','0.00','980','0','اضافة فاتورة مبيعات','149100', '980', '2024-12-12 12:52:59', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '980', '0', null, '0', null, null,'', '0','1','1','980','1','2024-12-12 12:50:32','0','0');
UPDATE client SET  inUse = 0 where clientid = 8939;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35663;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07020', '149100', '5', '16041', '1', '240', '240', '0', '', '1', '2024-12-12 12:52:59', '16041', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35663-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 173.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 173.00
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 157, lastbuyprice_withDiscountAndTax = 190
                where sellbilldetailid = 544814;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16041, '2024-12-12', 240, 190, 190
                    , 173, 190, 173, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 190, 157, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+173
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+173
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , 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-12', 240, 190, 190
                    , 173, 190, 173, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 157, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+173
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+173
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , 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 = '7', userid = '75', storedetaildate = '2024-12-12 12:52:59' WHERE storedetailid = '16040';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16041', '1', '1', '1', '149100', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-12 12:52:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36004;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149100', '5', '15970', '1', '200', '200', '0', '', '1', '2024-12-12 12:53:00', '15970', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36004-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 = 128, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 544815;
 INSERT INTO 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-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:53:00' WHERE storedetailid = '15969';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15970', '1', '1', '1', '149100', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-2', '-3', '75', '2024-12-12 12:53:00','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35039;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06952', '149100', '5', '15878', '1', '280', '280', '0', '', '1', '2024-12-12 12:53:00', '15878', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35039-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 = 544816;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15878, '2024-12-12', 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-12', 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 = '2', userid = '75', storedetaildate = '2024-12-12 12:53:00' WHERE storedetailid = '15877';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15878', '1', '1', '1', '149100', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 12:53:00','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35267;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','41186', '149100', '5', '15870', '1', '230', '230', '0', '', '1', '2024-12-12 12:53:00', '15870', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35267-1,','1','1','0','0','230','230','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 = 163, lastbuyprice_withDiscountAndTax = 190
                where sellbilldetailid = 544817;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15870, '2024-12-12', 230, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 190, 163, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , 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-12', 230, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 163, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , 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 = '4', userid = '75', storedetaildate = '2024-12-12 12:53:00' WHERE storedetailid = '15869';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15870', '1', '1', '1', '149100', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 12:53: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', '149100', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 12:53: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', '149100', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-12 12:53:00', '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 = 81 where clientid = 8939;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 980, 750, 750
                    , 733, 750, 733, 750.62
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,750, 678, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+980, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+750, sellCostMeanBuyPrice = sellCostMeanBuyPrice+733
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+750, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+733
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+750.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+750
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+678
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8939, '2024-12-12', 980, 750, 750
                    , 733, 750, 733, 750.62
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,750, 678, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+980, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+750, sellCostMeanBuyPrice = sellCostMeanBuyPrice+733
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+750, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+733
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+750.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+750
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+678
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 980, 750, 750
                    , 733, 750, 733, 750.62, 750, 678)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+980, netSellCostBuyPrice = netSellCostBuyPrice+750
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+750
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+733
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+750
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+733
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+750.62
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+750
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+678;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675abff8cf1bb and sellbillId = 149100 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:23:00";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 12:53:00", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:53: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-12 09:23:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:53:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 12:53:24', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:23:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:53:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 12:53:36', '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-12', '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 = '12370',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('12420.00','50', '1', '1', 'إضافة مصروف', '25607', '12370', '2024-12-12 12:53:36', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'عبده صاله', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25607';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:23:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:53:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 12:53: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-12 09:23:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:53:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 12:53:38', '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-12 09:23:44";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:53:44", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:53:44', '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-12 09:24:31";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 12:54:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 12:54:31', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:24:48";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 12:54:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 12:54:48', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245721
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(188,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-174' , clientdate = '2024-12-12 12:54:48', userid = '2' WHERE clientid = '188';
UPDATE client SET  inUse = 0 where clientid = 188;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('188','216.00','390','1','ايصال تحصيل (( قبض من عميل ))','245721', '-174', '2024-12-12 12:50:21', '2', 'clientPayedDeptController.php', '   ', '390', '0', null, '0', null, null,'', '-1','1','1','390','1','','3105','0');
UPDATE save SET  savecurrentvalue = '429913.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('429523.50','390', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245723', '429913.5', '2024-12-12 12:54:48', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '390', '390', '2024-12-12', '2', '0', '0', '2024-12-12 12:54:48','اضافة ايصال سداد للعميل ايمان محروس f94','1','0','0','0','245723','clientPayedDeptController.php?do=show&id=245723');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121683', '-1', '390', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '390', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121683', '-1', '390', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-390', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '188', clientdebtchangebefore = '216.000', clientdebtchangeamount = '390.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245721', clientdebtchangeafter = '-174.000', clientdebtchangedate = '2024-12-12 12:50:21', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '390.00',discount='', reciptid='0', dailyentryid = '121683',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='390',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245723';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245721 -clientdebtchangeId = 245723
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245724
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245725
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:25:38";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 12:55:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 12:55:38', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:26:02";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 12:56:02", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 12:56:02', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245726
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245727
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ac08d0630e
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3193,@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-12 12:53:01', '0675ac08d0630e', '3193', '1.00', '440', '0', '1', '439.00', '439', '0', '439', '1', '2024-12-12 12:56:56', '', '75', '0', 'ام احمد A830', '2', '1', '3', '81', 'ام احمد A830', '5' ,'0','','','','','-1','0','0','0','0','0','439','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '440', userid = '75' WHERE clientid = '3193';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3193','1.00','439','0','اضافة فاتورة مبيعات','149101', '440', '2024-12-12 12:56:56', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '439', '0', null, '0', null, null,'', '0','1','1','439','1','2024-12-12 12:53:01','0','0');
UPDATE client SET  inUse = 0 where clientid = 3193;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32714;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('85','R2971', '149101', '1', '14560', '1', '60', '60', '0', '', '1', '2024-12-12 12:56:56', '14560', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32714-1,','1','1','0','0','60','60','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 85.00 , meanbuyprice = 82.00, lastbuyprice_withDiscount = 85.00, meanbuyprice_withDiscount = 82.00
        
                where sellbilldetailid = 544820;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14560, '2024-12-12', 60, 85, 85
                    , 82, 85, 82, 79.55
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+60, sellCostBuyPrice =sellCostBuyPrice+85
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+85, sellCostMeanBuyPrice = sellCostMeanBuyPrice+82
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+85, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+82
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+79.55
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 60, 85, 85
                    , 82, 85, 82, 79.55
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+60, sellCostBuyPrice =sellCostBuyPrice+85
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+85, sellCostMeanBuyPrice = sellCostMeanBuyPrice+82
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+85, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+82
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+79.55
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:56:56' WHERE storedetailid = '14559';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14560', '1', '1', '1', '149101', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 12:56:56','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2744', '149101', '1', '13494', '1', '95', '95', '0', '', '1', '2024-12-12 12:56:56', '13494', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','95','95','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 115.00 , meanbuyprice = 185.00, lastbuyprice_withDiscount = 115.00, meanbuyprice_withDiscount = 185.00
        
                where sellbilldetailid = 544821;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13494, '2024-12-12', 95, 115, 115
                    , 185, 115, 185, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+95, sellCostBuyPrice =sellCostBuyPrice+115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 95, 115, 115
                    , 185, 115, 185, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+95, sellCostBuyPrice =sellCostBuyPrice+115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 12:56:56' WHERE storedetailid = '13493';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13494', '1', '1', '1', '149101', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-3', '-4', '75', '2024-12-12 12:56:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 28723;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','05804', '149101', '5', '12789', '1', '260', '260', '0', '', '1', '2024-12-12 12:56:56', '12789', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','28723-1,','1','1','0','0','260','260','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
        
                where sellbilldetailid = 544822;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12789, '2024-12-12', 260, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 260, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-12 12:56:56' WHERE storedetailid = '12788';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12789', '1', '1', '1', '149101', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 12:56:56','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149101', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 12:56:56', '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', '149101', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-12 12:56:56', '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 = 81 where clientid = 3193;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 439, 530, 530
                    , 597, 530, 597, 524.55
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+439, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+597
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+597
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+524.55
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (3193, '2024-12-12', 439, 530, 530
                    , 597, 530, 597, 524.55
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+439, sellCostBuyPrice =sellCostBuyPrice+530
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+530, sellCostMeanBuyPrice = sellCostMeanBuyPrice+597
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+530, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+597
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+524.55
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 439, 530, 530
                    , 597, 530, 597, 524.55, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+439, netSellCostBuyPrice = netSellCostBuyPrice+530
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+530
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+597
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+530
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+597
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+524.55
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ac08d0630e and sellbillId = 149101 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245728
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245728 -clientdebtchangeId = 245729
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:26:59";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 12:56:59", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 12:56:59', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('اية عبد العظيم 33' , '', '', '01098122390', '0', '', '0', '2024-12-12 12:57:38', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-12','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10679', '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 ('10679','0','0','0','إضافة عميل جديد','10679', '0', '2024-12-12 12:57:38', '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-12 12:57:38');
UPDATE client SET clientname = 'اية عبد العظيم 33', clientaddress = '', clientphone = '', clientmobile = '01098122390', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-12', 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='12410',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10679';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:27:39";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 12:57:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 12:57:39', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245730
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245730 -clientdebtchangeId = 245731
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245732
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10196,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '82' , clientdate = '2024-12-12 12:58:00', userid = '2' WHERE clientid = '10196';
UPDATE client SET  inUse = 0 where clientid = 10196;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10196','187.00','105','1','ايصال تحصيل (( قبض من عميل ))','245732', '82', '2024-12-12 12:57:40', '2', 'clientPayedDeptController.php', '   ', '105', '0', null, '0', null, null,'', '-1','1','1','105','1','','3112','0');
UPDATE save SET  savecurrentvalue = '439607.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('439502.50','105', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245732', '439607.5', '2024-12-12 12:58:00', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '105', '105', '2024-12-12', '2', '0', '0', '2024-12-12 12:58:00','اضافة ايصال سداد للعميل ريهام رمضان 33','1','0','0','0','245732','clientPayedDeptController.php?do=show&id=245732');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121690', '-1', '105', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '105', 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 ('121690', '10641', '105', '','0');
UPDATE accountstree SET name = 'ريهام رمضان 33', customName = 'ريهام رمضان 33', customNameEn = 'ريهام رمضان 33', nameEn = 'ريهام رمضان 33', parent = '58', accountNature = '0', theValue = '-1721', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-10-25 15:00:51' WHERE id = '10641';
UPDATE clientdebtchange SET clientid = '10196', clientdebtchangebefore = '187.000', clientdebtchangeamount = '105.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245732', clientdebtchangeafter = '82.000', clientdebtchangedate = '2024-12-12 12:57:40', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '105.00',discount='', reciptid='0', dailyentryid = '121690',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='105',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245732';
COMMIT;

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

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

BEGIN;
CALL clientInUse(10679,@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-12 12:45:53', '0675abee1db17c', '10679', '0.00', '424', '0', '1', '424.00', '424', '0', '424', '1', '2024-12-12 12:58:15', '', '75', '0', 'اية عبد العظيم 33', '2', '1', '3', '89', 'اية عبد العظيم 33', '3' ,'0','','','','','-1','0','0','0','0','0','424','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '424', userid = '75' WHERE clientid = '10679';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10679','0.00','424','0','اضافة فاتورة مبيعات','149102', '424', '2024-12-12 12:58:15', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '424', '0', null, '0', null, null,'', '0','1','1','424','1','2024-12-12 12:45:53','0','0');
UPDATE client SET  inUse = 0 where clientid = 10679;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35880;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149102', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-12 12:58:15', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35880-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 = 544825;
 INSERT INTO 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-12', 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-12', 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 = '56', userid = '75', storedetaildate = '2024-12-12 12: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', '149102', 'اضافة فاتورة مبيعات', 'sellbillController.php', '57', '56', '75', '2024-12-12 12:58:15','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149102', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 12:58:15', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149102', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-12 12:58:15', '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 = 89 where clientid = 10679;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 424, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+424, 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 (10679, '2024-12-12', 424, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+424, 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, 424, 335, 335
                    , 335, 335, 335, 335, 335, 285)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+424, 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 0675abee1db17c and sellbillId = 149102 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245733
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245733 -clientdebtchangeId = 245734
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245735
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:28:57";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 12:58:57", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 12:58:57', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:29:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 12:59:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:59: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 0675ac1e3b18a8
-- ----------------------------------------------------------------------------------------------------

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-12 12:58:43', '0675ac1e3b18a8', '1', '0.00', '0', '0', '1', '450.00', '450', '450', '0', '1', '2024-12-12 12:59:14', '', '104', '0', 'نقدي', '1', '0', '3', '93', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149103', '0', '2024-12-12 12:59:14', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '450', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 12:58:43','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35646;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('375','H1569', '149103', '14', '16178', '1', '450', '450', '0', '', '1', '2024-12-12 12:59:14', '16178', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35646-1,','1','1','0','0','450','450','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 375.00 , meanbuyprice = 375.00, lastbuyprice_withDiscount = 375.00, meanbuyprice_withDiscount = 375.00
        , lastbuyprice_withTax = 375, meanbuyprice_withTax = 375, lastbuyprice_withDiscountAndTax = 375
                where sellbilldetailid = 544828;
 INSERT INTO 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-12', 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-12', 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 = '10', userid = '104', storedetaildate = '2024-12-12 12:59:14' WHERE storedetailid = '16177';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16178', '1', '1', '1', '149103', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '104', '2024-12-12 12:59:14','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '12820',  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 ('12370','450', '0', '1', 'اضافة فاتورة مبيعات', '149103', '12820', '2024-12-12 12:59:14', '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-12', 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-12', 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 0675ac1e3b18a8 and sellbillId = 149103 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245736
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245736 -clientdebtchangeId = 245737
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:29:17";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 12:59:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 12:59:17', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:29:17";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 12:59:17", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 12:59: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 0675ac1c7d7bbb
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10373,@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-12 12:58:15', '0675ac1c7d7bbb', '10373', '0.00', '263', '0', '1', '263.00', '263', '0', '263', '1', '2024-12-12 12:59:17', '', '75', '0', 'ام احمد القاهرة 33', '2', '1', '3', '89', 'ام احمد القاهرة 33', '3' ,'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-12','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 = '10373';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10373','0.00','263','0','اضافة فاتورة مبيعات','149104', '263', '2024-12-12 12:59:17', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '263', '0', null, '0', null, null,'', '0','1','1','263','1','2024-12-12 12:58:15','0','0');
UPDATE client SET  inUse = 0 where clientid = 10373;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35593;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149104', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-12 12:59:17', '15850', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35593-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 = 544829;
 INSERT INTO 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-12', 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-12', 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 = '65', userid = '75', storedetaildate = '2024-12-12 12:59:17' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '1', '149104', 'اضافة فاتورة مبيعات', 'sellbillController.php', '66', '65', '75', '2024-12-12 12:59: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', '149104', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 12:59: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', '149104', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-12 12:59:18', '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 = 89 where clientid = 10373;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 263, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,190, 188, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+263, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10373, '2024-12-12', 263, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,190, 188, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+263, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 263, 190, 190
                    , 190, 190, 190, 190, 190, 188)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+263, 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 0675ac1c7d7bbb and sellbillId = 149104 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245738
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245738 -clientdebtchangeId = 245739
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245740
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245741
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10626,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12 13:00:14', 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','838.00','838','1','ايصال تحصيل (( قبض من عميل ))','245741', '0', '2024-12-12 12:59:56', '2', 'clientPayedDeptController.php', '   ', '838', '0', null, '0', null, null,'', '-1','1','1','838','1','','3118','0');
UPDATE save SET  savecurrentvalue = '448737.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('447899.50','838', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245741', '448737.5', '2024-12-12 13:00:14', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '838', '838', '2024-12-12', '2', '0', '0', '2024-12-12 13:00:14','اضافة ايصال سداد للعميل هند محمد فريد','1','0','0','0','245741','clientPayedDeptController.php?do=show&id=245741');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121696', '-1', '838', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '838', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121696', '12292', '838', '','0');
UPDATE accountstree SET name = 'هند محمد فريد', customName = 'هند محمد فريد', customNameEn = 'هند محمد فريد', nameEn = 'هند محمد فريد', parent = '58', accountNature = '0', theValue = '-3464', 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 = '838.000', clientdebtchangeamount = '838.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245741', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-12 12:59:56', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '838.00',discount='', reciptid='0', dailyentryid = '121696',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='838',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245741';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245742
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6327,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12 13:00:33', userid = '2' WHERE clientid = '6327';
UPDATE client SET  inUse = 0 where clientid = 6327;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6327','818.00','818','1','ايصال تحصيل (( قبض من عميل ))','245742', '0', '2024-12-12 13:00:15', '2', 'clientPayedDeptController.php', '   ', '818', '0', null, '0', null, null,'', '-1','1','1','818','1','','3119','0');
UPDATE save SET  savecurrentvalue = '449555.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('448737.50','818', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245742', '449555.5', '2024-12-12 13:00:33', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '818', '818', '2024-12-12', '2', '0', '0', '2024-12-12 13:00:33','اضافة ايصال سداد للعميل اميرة شلبي 14','1','0','0','0','245742','clientPayedDeptController.php?do=show&id=245742');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121697', '-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 ('121697', '-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;
UPDATE clientdebtchange SET clientid = '6327', clientdebtchangebefore = '818.000', clientdebtchangeamount = '818.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245742', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-12 13:00:15', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '818.00',discount='', reciptid='0', dailyentryid = '121697',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='818',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245742';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:30:34";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:00:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 13:00:34', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:30:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:00:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:00: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 0675ac1e2b8ceb
-- ----------------------------------------------------------------------------------------------------

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-12 12:58:42', '0675ac1e2b8ceb', '1', '0.00', '0', '0', '1', '2080.00', '2080', '2080', '0', '1', '2024-12-12 13:00:42', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '8' ,'0','','','','','-1','0','0','0','0','0','2080','0','','0','0','2080','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149105', '0', '2024-12-12 13:00:42', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2080', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 12:58:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35603;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07129', '149105', '5', '16154', '1', '200', '200', '0', '', '1', '2024-12-12 13:00:42', '16154', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35603-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 = 544832;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16154, '2024-12-12', 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-12', 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 = '2', userid = '104', storedetaildate = '2024-12-12 13:00:42' WHERE storedetailid = '16153';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16154', '1', '1', '1', '149105', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '104', '2024-12-12 13:00:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35607;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('170','07132', '149105', '5', '16156', '1', '240', '240', '0', '', '1', '2024-12-12 13:00:42', '16156', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35607-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where sellbilldetailid = 544833;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16156, '2024-12-12', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '104', storedetaildate = '2024-12-12 13:00:42' WHERE storedetailid = '16155';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16156', '1', '1', '1', '149105', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '104', '2024-12-12 13:00:42','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', '149105', '5', '16117', '1', '280', '280', '0', '', '1', '2024-12-12 13:00:42', '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 = 544834;
 INSERT INTO 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-12', 280, 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+280, 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-12', 280, 240, 240
                    , 235, 240, 235, 227.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 229, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, 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 = '38', userid = '104', storedetaildate = '2024-12-12 13:00:42' WHERE storedetailid = '16116';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16117', '1', '1', '1', '149105', 'اضافة فاتورة مبيعات', 'sellbillController.php', '39', '38', '104', '2024-12-12 13:00:42','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', '149105', '5', '16189', '1', '220', '220', '0', '', '1', '2024-12-12 13:00:42', '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 = 544835;
 INSERT INTO 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-12', 220, 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+220, 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-12', 220, 170, 170
                    , 170, 170, 170, 169.92
                    , 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+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 = '7', userid = '104', storedetaildate = '2024-12-12 13:00:42' WHERE storedetailid = '16188';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16189', '1', '1', '1', '149105', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '104', '2024-12-12 13:00:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35691;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('165','07149', '149105', '5', '16195', '1', '220', '220', '0', '', '1', '2024-12-12 13:00:42', '16195', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35691-1,','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 165, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 544836;
 INSERT INTO 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-12', 220, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 220, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+165
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '104', storedetaildate = '2024-12-12 13:00:42' WHERE storedetailid = '16194';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16195', '1', '1', '1', '149105', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '104', '2024-12-12 13:00:42','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149105', '5', '16247', '1', '200', '200', '0', '', '1', '2024-12-12 13:00:42', '16247', '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 = 170.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 544837;
 INSERT INTO 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-12', 200, 140, 200
                    , 170, 200, 170, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , 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-12', 200, 140, 200
                    , 170, 200, 170, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , 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 = '-19', userid = '104', storedetaildate = '2024-12-12 13:00:42' WHERE storedetailid = '16246';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16247', '1', '1', '1', '149105', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-18', '-19', '104', '2024-12-12 13:00:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35694;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07111', '149105', '5', '16128', '1', '420', '420', '0', '', '1', '2024-12-12 13:00:42', '16128', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35694-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 = 544838;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16128, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '29', userid = '104', storedetaildate = '2024-12-12 13:00:42' WHERE storedetailid = '16127';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16128', '1', '1', '1', '149105', 'اضافة فاتورة مبيعات', 'sellbillController.php', '30', '29', '104', '2024-12-12 13:00:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35753;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07163', '149105', '5', '16225', '1', '300', '300', '0', '', '1', '2024-12-12 13:00:42', '16225', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35753-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 = 544839;
 INSERT INTO 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-12', 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-12', 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 = '16', userid = '104', storedetaildate = '2024-12-12 13:00:42' WHERE storedetailid = '16224';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16225', '1', '1', '1', '149105', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '104', '2024-12-12 13:00:42','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '14900',  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 ('12820','2080', '0', '1', 'اضافة فاتورة مبيعات', '149105', '14900', '2024-12-12 13:00:42', '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-12', 2080, 1635, 1695
                    , 1660, 1695, 1660, 1682.42
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1695, 1684, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2080, sellCostBuyPrice =sellCostBuyPrice+1635
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1695, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1695, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1682.42
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1695
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1684
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 2080, 1635, 1695
                    , 1660, 1695, 1660, 1682.42
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1695, 1684, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2080, sellCostBuyPrice =sellCostBuyPrice+1635
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1695, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1695, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1682.42
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1695
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1684
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2080, 1635, 1695
                    , 1660, 1695, 1660, 1682.42, 1695, 1684)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2080, netSellCostBuyPrice = netSellCostBuyPrice+1635
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1695
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1660
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1695
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1660
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1682.42
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1695
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1684;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ac1e2b8ceb and sellbillId = 149105 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245743
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10673,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '1' , clientdate = '2024-12-12 13:00:55', userid = '2' WHERE clientid = '10673';
UPDATE client SET  inUse = 0 where clientid = 10673;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10673','561.00','560','1','ايصال تحصيل (( قبض من عميل ))','245743', '1', '2024-12-12 13:00:34', '2', 'clientPayedDeptController.php', '   ', '560', '0', null, '0', null, null,'', '-1','1','1','560','1','','3120','0');
UPDATE save SET  savecurrentvalue = '450115.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('449555.50','560', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245744', '450115.5', '2024-12-12 13:00:55', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '560', '560', '2024-12-12', '2', '0', '0', '2024-12-12 13:00:55','اضافة ايصال سداد للعميل دينا شريف 41 م','1','0','0','0','245744','clientPayedDeptController.php?do=show&id=245744');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121698', '-1', '560', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '560', 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 ('121698', '12389', '560', '','0');
UPDATE accountstree SET name = 'دينا شريف 41 م', customName = 'دينا شريف 41 م', customNameEn = 'دينا شريف 41 م', nameEn = 'دينا شريف 41 م', parent = '58', accountNature = '0', theValue = '-560', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-11 13:59:51' WHERE id = '12389';
UPDATE clientdebtchange SET clientid = '10673', clientdebtchangebefore = '561.000', clientdebtchangeamount = '560.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245743', clientdebtchangeafter = '1.000', clientdebtchangedate = '2024-12-12 13:00:34', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '560.00',discount='', reciptid='0', dailyentryid = '121698',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='560',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245744';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245743 -clientdebtchangeId = 245744
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245745
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ac206bb8f8
-- ----------------------------------------------------------------------------------------------------

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-12 12:59:18', '0675ac206bb8f8', '10296', '1.00', '1420', '0', '1', '1419.00', '1419', '0', '1419', '1', '2024-12-12 13:01:40', '', '75', '0', 'اسماء طنطا 58', '2', '1', '3', '80', 'اسماء طنطا 58', '7' ,'0','','','','','-1','0','0','0','0','0','1419','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1420', 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','1.00','1419','0','اضافة فاتورة مبيعات','149106', '1420', '2024-12-12 13:01:40', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1419', '0', null, '0', null, null,'', '0','1','1','1419','1','2024-12-12 12:59:18','0','0');
UPDATE client SET  inUse = 0 where clientid = 10296;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35597;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149106', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-12 13:01:40', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35597-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 = 544840;
 INSERT INTO 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-12', 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-12', 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 = '111', userid = '75', storedetaildate = '2024-12-12 13:01:40' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '149106', 'اضافة فاتورة مبيعات', 'sellbillController.php', '112', '111', '75', '2024-12-12 13:01:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33003;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06504', '149106', '5', '14835', '1', '275', '275', '0', '', '1', '2024-12-12 13:01:40', '14835', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33003-1,','1','1','0','0','275','275','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 = 544841;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14835, '2024-12-12', 275, 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+275, 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-12', 275, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275, 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-12 13:01:40' WHERE storedetailid = '14834';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14835', '1', '1', '1', '149106', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 13:01:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33858;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06731', '149106', '5', '15272', '1', '240', '240', '0', '', '1', '2024-12-12 13:01:40', '15272', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33858-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 260.00
        
                where sellbilldetailid = 544842;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15272, '2024-12-12', 240, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 240, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-12 13:01:40' WHERE storedetailid = '15271';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15272', '1', '1', '1', '149106', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 13:01:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33679;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06691', '149106', '5', '15204', '1', '150', '150', '0', '', '1', '2024-12-12 13:01:40', '15204', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33679-1,','1','1','0','0','150','150','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        
                where sellbilldetailid = 544843;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15204, '2024-12-12', 150, 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+150, 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-12', 150, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+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 = '4', userid = '75', storedetaildate = '2024-12-12 13:01:40' WHERE storedetailid = '15203';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15204', '1', '1', '1', '149106', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 13:01:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35593;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149106', '5', '15850', '1', '240', '240', '0', '', '1', '2024-12-12 13:01:40', '15850', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35593-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 = 544844;
 INSERT INTO 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-12', 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-12', 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 = '64', userid = '75', storedetaildate = '2024-12-12 13:01:40' WHERE storedetailid = '15849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15850', '1', '1', '1', '149106', 'اضافة فاتورة مبيعات', 'sellbillController.php', '65', '64', '75', '2024-12-12 13:01: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', '149106', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 13:01:40', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149106', '17', '10291', '1', '14', '14', '0', '', '1', '2024-12-12 13:01:40', '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 = 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-12', 1419, 1270, 1270
                    , 1270, 1270, 1270, 1270
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,610, 608, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1419, sellCostBuyPrice =sellCostBuyPrice+1270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+610
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+608
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10296, '2024-12-12', 1419, 1270, 1270
                    , 1270, 1270, 1270, 1270
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,610, 608, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1419, sellCostBuyPrice =sellCostBuyPrice+1270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+610
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+608
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1419, 1270, 1270
                    , 1270, 1270, 1270, 1270, 610, 608)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1419, netSellCostBuyPrice = netSellCostBuyPrice+1270
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1270
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1270
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1270
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1270
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1270
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+610
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+608;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ac206bb8f8 and sellbillId = 149106 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

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-12 13:00:43', '0675ac25b47bd6', '1', '0.00', '0', '0', '1', '500.00', '500', '500', '0', '1', '2024-12-12 13:01:50', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','500','0','','0','0','500','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149107', '0', '2024-12-12 13:01:50', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '500', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 13:00:43','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', '149107', '5', '16347', '1', '200', '200', '0', '', '1', '2024-12-12 13:01:50', '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 = 544847;
 INSERT INTO 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-12', 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-12', 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 = '23', userid = '104', storedetaildate = '2024-12-12 13:01:50' WHERE storedetailid = '16346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16347', '1', '1', '1', '149107', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '104', '2024-12-12 13:01:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35929;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','07200', '149107', '5', '16305', '1', '300', '300', '0', '', '1', '2024-12-12 13:01:50', '16305', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35929-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 544848;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16305, '2024-12-12', 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-12', 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 = '11', userid = '104', storedetaildate = '2024-12-12 13:01:50' WHERE storedetailid = '16304';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16305', '1', '1', '1', '149107', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '104', '2024-12-12 13:01:50','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '15400',  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 ('14900','500', '0', '1', 'اضافة فاتورة مبيعات', '149107', '15400', '2024-12-12 13:01: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-12', 500, 390, 390
                    , 387, 390, 387, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,390, 384, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+387
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+387
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+390
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+390
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+384
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 500, 390, 390
                    , 387, 390, 387, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,390, 384, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+387
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+387
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+390
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+390
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+384
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 500, 390, 390
                    , 387, 390, 387, 390, 390, 384)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+500, netSellCostBuyPrice = netSellCostBuyPrice+390
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+390
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+387
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+390
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+387
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+390
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+390
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+384;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ac25b47bd6 and sellbillId = 149107 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:31:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:01:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:01: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-12 09:33:57";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:03:57", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 13:03:57', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245746
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10601,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '737' , clientdate = '2024-12-12 13:03:57', userid = '2' WHERE clientid = '10601';
UPDATE client SET  inUse = 0 where clientid = 10601;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10601','2227.00','1490','1','ايصال تحصيل (( قبض من عميل ))','245746', '737', '2024-12-12 13:01:35', '2', 'clientPayedDeptController.php', '   ', '1490', '0', null, '0', null, null,'', '-1','1','1','1490','1','','3122','0');
UPDATE save SET  savecurrentvalue = '451605.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('450115.50','1490', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245748', '451605.5', '2024-12-12 13:03:57', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1490', '1490', '2024-12-12', '2', '0', '0', '2024-12-12 13:03:57','اضافة ايصال سداد للعميل ندي حامد 07','1','0','0','0','245748','clientPayedDeptController.php?do=show&id=245748');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121700', '-1', '1490', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1490', 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 ('121700', '12226', '1490', '','0');
UPDATE accountstree SET name = 'ندي حامد 07', customName = 'ندي حامد 07', customNameEn = 'ندي حامد 07', nameEn = 'ندي حامد 07', parent = '58', accountNature = '0', theValue = '-1490', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-05 17:57:52' WHERE id = '12226';
UPDATE clientdebtchange SET clientid = '10601', clientdebtchangebefore = '2227.000', clientdebtchangeamount = '1490.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245746', clientdebtchangeafter = '737.000', clientdebtchangedate = '2024-12-12 13:01:35', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1490.00',discount='', reciptid='0', dailyentryid = '121700',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1490',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245748';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245746 -clientdebtchangeId = 245748
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245749
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245750
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:35:38";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:05:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 13:05:38', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:36:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:06:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 13:06:54', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE userid = 2;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:37:48";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:07:48", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 13:07:48', '75', '', '192.168.1.16', '', '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-12 09:37:48";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:37:51";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:07:51", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:07:51', '75', 'addsellBill', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:38:58";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 13:08:58", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:08:58', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ac2954cb13
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6504,@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-12 13:01:41', '0675ac2954cb13', '6504', '19.00', '797', '0', '1', '778.00', '778', '0', '778', '1', '2024-12-12 13:08:59', '', '75', '0', 'ضحي كمال 41', '2', '1', '3', '87', 'ضحي كمال 41', '6' ,'0','','','','','-1','0','0','0','0','0','778','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '797', userid = '75' WHERE clientid = '6504';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6504','19.00','778','0','اضافة فاتورة مبيعات','149108', '797', '2024-12-12 13:08:59', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '778', '0', null, '0', null, null,'', '0','1','1','778','1','2024-12-12 13:01:41','0','0');
UPDATE client SET  inUse = 0 where clientid = 6504;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32362;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2861', '149108', '1', '14255', '1', '120', '120', '0', '', '1', '2024-12-12 13:08:59', '14255', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32362-1,','1','1','0','0','120','120','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 160.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 160.00
        
                where sellbilldetailid = 544849;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14255, '2024-12-12', 120, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 120, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 13:08:59' WHERE storedetailid = '14254';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14255', '1', '1', '1', '149108', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-12 13:08:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32672;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2993', '149108', '1', '14614', '1', '270', '270', '0', '', '1', '2024-12-12 13:08:59', '14614', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32672-1,','1','1','0','0','270','270','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 245.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 245.00, meanbuyprice_withDiscount = 270.00
        , lastbuyprice_withTax = 245, meanbuyprice_withTax = 61, lastbuyprice_withDiscountAndTax = 245
                where sellbilldetailid = 544850;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14614, '2024-12-12', 270, 245, 245
                    , 270, 245, 270, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 245, 61, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+61
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 270, 245, 245
                    , 270, 245, 270, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 245, 61, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+61
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 13:08:59' WHERE storedetailid = '14613';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14614', '1', '1', '1', '149108', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 13:08:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33183;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('230','R2956', '149108', '1', '14505', '1', '190', '190', '0', '', '1', '2024-12-12 13:08:59', '14505', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33183-1,','1','1','0','0','190','190','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 = 544851;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14505, '2024-12-12', 190, 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+190, 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-12', 190, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, 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 = '6', userid = '75', storedetaildate = '2024-12-12 13:08:59' WHERE storedetailid = '14504';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14505', '1', '1', '1', '149108', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-12 13:08:59','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', '149108', '1', '14071', '1', '170', '170', '0', '', '1', '2024-12-12 13:08:59', '14071', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31335-1,','1','1','0','0','170','170','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 = 544852;
 INSERT INTO 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-12', 170, 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+170, 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-12', 170, 190, 190
                    , 215, 190, 215, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, 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 = '7', userid = '75', storedetaildate = '2024-12-12 13:08:59' WHERE storedetailid = '14070';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14071', '1', '1', '1', '149108', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-12 13:08:59','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149108', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 13:08:59', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149108', '17', '10291', '1', '8', '8', '0', '', '1', '2024-12-12 13:08:59', '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 = 87 where clientid = 6504;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 778, 825, 825
                    , 875, 825, 875, 825
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,245, 61, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+778, sellCostBuyPrice =sellCostBuyPrice+825
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+825, sellCostMeanBuyPrice = sellCostMeanBuyPrice+875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+825, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+825
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+61
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6504, '2024-12-12', 778, 825, 825
                    , 875, 825, 875, 825
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,245, 61, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+778, sellCostBuyPrice =sellCostBuyPrice+825
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+825, sellCostMeanBuyPrice = sellCostMeanBuyPrice+875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+825, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+825
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+61
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 778, 825, 825
                    , 875, 825, 875, 825, 245, 61)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+778, netSellCostBuyPrice = netSellCostBuyPrice+825
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+825
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+875
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+825
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+875
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+825
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+245
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+61;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ac2954cb13 and sellbillId = 149108 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245751
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10601,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '27' , clientdate = '2024-12-12 13:09:19', userid = '104' WHERE clientid = '10601';
UPDATE client SET  inUse = 0 where clientid = 10601;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10601','737.00','710','1','ايصال تحصيل (( قبض من عميل ))','245751', '27', '2024-12-12 13:06:54', '104', 'clientPayedDeptController.php', '   ', '710', '0', null, '0', null, null,'', '-1','1','1','710','1','','3125','0');
UPDATE save SET  savecurrentvalue = '16110',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('15400.00','710', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '245752', '16110', '2024-12-12 13:09:19', '104',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '710', '710', '2024-12-12', '104', '0', '0', '2024-12-12 13:09:19','اضافة ايصال سداد للعميل ندي حامد 07','1','0','-1','0','245752','clientPayedDeptController.php?do=show&id=245752');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121703', '-1', '710', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '710', 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 ('121703', '12226', '710', '','0');
UPDATE accountstree SET name = 'ندي حامد 07', customName = 'ندي حامد 07', customNameEn = 'ندي حامد 07', nameEn = 'ندي حامد 07', parent = '58', accountNature = '0', theValue = '-2200', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-05 17:57:52' WHERE id = '12226';
UPDATE clientdebtchange SET clientid = '10601', clientdebtchangebefore = '737.000', clientdebtchangeamount = '710.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245751', clientdebtchangeafter = '27.000', clientdebtchangedate = '2024-12-12 13:06:54', userid = '104', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '710.00',discount='', reciptid='0', dailyentryid = '121703',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='710',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245752';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245751 -clientdebtchangeId = 245752
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:39:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:09:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 13:09:19', '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-12 09:39:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:09:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 13:09:21', '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-12 09:43:53";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:13:53", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:13: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-12 09:44:03";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:14:03", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:14:03', '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-12', '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 = '15910',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('16110.00','200', '1', '1', 'إضافة مصروف', '25608', '15910', '2024-12-12 13:14:04', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'النون', expensesdetails = '', expensesValue = '200.00', expensesdate = '2024-12-12', 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 = '25608';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:44:04";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:14:04", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:14:04', '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-12 09:44:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:14:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:14:06', '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-12 09:44:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:14:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:14:21', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:44:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:14:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:14:41', '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-12', '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 = '15860',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('15910.00','50', '1', '1', 'إضافة مصروف', '25609', '15860', '2024-12-12 13:14:41', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كشف حساب بريد', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25609';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:44:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:14:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:14:42', '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-12 09:44:43";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:14:43", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:14:43', '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-12 09:45:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:15:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:15: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-12 09:45:09";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:15:09", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:15:09', '75', 'addAndRetuen', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ac407b0254
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2923,@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-12 13:07:51', '0675ac407b0254', '2923', '-1.00', '7042', '270', '1', '7313.00', '7043', '0', '7043', '1', '2024-12-12 13:15:09', '', '75', '0', 'دينا فريد k200', '2', '1', '3', '79', 'دينا فريد k200', '20' ,'0','','','','','-1','0','0','0','0','0','7043','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '7042', userid = '75' WHERE clientid = '2923';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2923','-1.00','7043','0','اضافة فاتورة مبيعات','149109', '7042', '2024-12-12 13:15:09', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '7043', '0', null, '0', null, null,'', '0','1','1','7043','1','2024-12-12 13:07:51','0','0');
UPDATE client SET  inUse = 0 where clientid = 2923;
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', '149109', '1', '16277', '2', '650', '1300', '0', '', '1', '2024-12-12 13:15:09', '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 = 544855;
 INSERT INTO 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-12', 1252.0032818269, 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+1252.0032818269, 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-12', 1252.0032818269, 1100, 1100
                    , 1098, 1100, 1094, 1093.34
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1100, 1096, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1252.0032818269, 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 = '79', userid = '75', storedetaildate = '2024-12-12 13:15:09' WHERE storedetailid = '16276';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16277', '1', '2', '1', '149109', 'اضافة فاتورة مبيعات', 'sellbillController.php', '81', '79', '75', '2024-12-12 13:15:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35611;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07104', '149109', '5', '16116', '1', '280', '280', '0', '', '1', '2024-12-12 13:15:09', '16116', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35611-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 = 544856;
 INSERT INTO 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-12', 269.66224531656, 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+269.66224531656, 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-12', 269.66224531656, 240, 240
                    , 236, 240, 236, 230.77
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 231, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+269.66224531656, 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 = '30', userid = '75', storedetaildate = '2024-12-12 13:15:09' WHERE storedetailid = '16115';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16116', '1', '1', '1', '149109', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31', '30', '75', '2024-12-12 13:15:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35899;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149109', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-12 13:15:09', '16293', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35899-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 = 544857;
 INSERT INTO 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-12', 192.61588951183, 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+192.61588951183, 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-12', 192.61588951183, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+192.61588951183, 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-12 13:15:09' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '149109', 'اضافة فاتورة مبيعات', 'sellbillController.php', '39', '38', '75', '2024-12-12 13:15:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 36058;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149109', '5', '16278', '3', '200', '600', '0', '', '1', '2024-12-12 13:15:09', '16278', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36058-3,','1','1','0','0','200','600','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 = 544858;
 INSERT INTO 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-12', 577.84766853548, 465, 465
                    , 444, 465, 444, 465
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 465, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+577.84766853548, sellCostBuyPrice =sellCostBuyPrice+465
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+465, sellCostMeanBuyPrice = sellCostMeanBuyPrice+444
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+465, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+444
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+465
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+465
                            , 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-12', 577.84766853548, 465, 465
                    , 444, 465, 444, 465
                    , 0, 0, 0, 0
                    , 0, 0, 0, 465, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+577.84766853548, sellCostBuyPrice =sellCostBuyPrice+465
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+465, sellCostMeanBuyPrice = sellCostMeanBuyPrice+444
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+465, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+444
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+465
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+465
                            , 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 = '36', userid = '75', storedetaildate = '2024-12-12 13:15:09' WHERE storedetailid = '16277';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16278', '1', '3', '1', '149109', 'اضافة فاتورة مبيعات', 'sellbillController.php', '39', '36', '75', '2024-12-12 13:15:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35913;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06861', '149109', '5', '15635', '1', '300', '300', '0', '', '1', '2024-12-12 13:15:09', '15635', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35913-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 302.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 302.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 432, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 544859;
 INSERT INTO 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-12', 288.92383426774, 250, 250
                    , 302, 250, 302, 236
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 432, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+288.92383426774, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+236
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+432
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 288.92383426774, 250, 250
                    , 302, 250, 302, 236
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 432, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+288.92383426774, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+302
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+302
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+236
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+432
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 13:15:09' WHERE storedetailid = '15634';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15635', '1', '1', '1', '149109', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-12 13:15:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35806;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149109', '5', '16234', '1', '550', '550', '0', '', '1', '2024-12-12 13:15:09', '16234', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35806-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 = 544860;
 INSERT INTO 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-12', 529.69369615753, 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+529.69369615753, 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-12', 529.69369615753, 455, 455
                    , 455, 455, 455, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+529.69369615753, 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 = '39', userid = '75', storedetaildate = '2024-12-12 13:15:09' WHERE storedetailid = '16233';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16234', '1', '1', '1', '149109', 'اضافة فاتورة مبيعات', 'sellbillController.php', '40', '39', '75', '2024-12-12 13:15:09','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', '149109', '5', '16117', '1', '280', '280', '0', '', '1', '2024-12-12 13:15:09', '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 = 544861;
 INSERT INTO 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-12', 269.66224531656, 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+269.66224531656, 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-12', 269.66224531656, 240, 240
                    , 235, 240, 235, 227.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 229, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+269.66224531656, 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 = '37', userid = '75', storedetaildate = '2024-12-12 13:15:09' WHERE storedetailid = '16116';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16117', '1', '1', '1', '149109', 'اضافة فاتورة مبيعات', 'sellbillController.php', '38', '37', '75', '2024-12-12 13:15:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35928;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('280','07198', '149109', '5', '16304', '1', '320', '320', '0', '', '1', '2024-12-12 13:15:09', '16304', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35928-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 280, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 544862;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16304, '2024-12-12', 308.18542321893, 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+308.18542321893, 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-12', 308.18542321893, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+308.18542321893, 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 = '13', userid = '75', storedetaildate = '2024-12-12 13:15:09' WHERE storedetailid = '16303';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16304', '1', '1', '1', '149109', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-12 13:15:09','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+5 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', '149109', '5', '16297', '5', '580', '2900', '0', '', '1', '2024-12-12 13:15:09', '16297', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35910-5,','1','1','0','0','580','2900','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 = 544863;
 INSERT INTO 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-12', 2792.9303979215, 2550, 2550
                    , 2550, 2550, 2550, 2550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 5, 0, 2550, 2550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2792.9303979215, sellCostBuyPrice =sellCostBuyPrice+2550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-12', 2792.9303979215, 2550, 2550
                    , 2550, 2550, 2550, 2550
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2550, 2550, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2792.9303979215, sellCostBuyPrice =sellCostBuyPrice+2550
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2550
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2550
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2550
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2550
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '74', userid = '75', storedetaildate = '2024-12-12 13:15:10' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '5', '1', '149109', 'اضافة فاتورة مبيعات', 'sellbillController.php', '79', '74', '75', '2024-12-12 13:15:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36119;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149109', '5', '16022', '1', '200', '200', '0', '', '1', '2024-12-12 13:15:10', '16022', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36119-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 = 544864;
 INSERT INTO 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-12', 192.61588951183, 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+192.61588951183, 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-12', 192.61588951183, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+192.61588951183, 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 = '2', userid = '75', storedetaildate = '2024-12-12 13:15:10' WHERE storedetailid = '16021';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16022', '1', '1', '1', '149109', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 13:15:10','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35972;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1632', '149109', '14', '16320', '1', '290', '290', '0', '', '1', '2024-12-12 13:15:10', '16320', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35972-1,','1','1','0','0','290','290','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 = 544865;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16320, '2024-12-12', 279.29303979215, 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+279.29303979215, 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-12', 279.29303979215, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 220, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+279.29303979215, 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 = '2', userid = '75', storedetaildate = '2024-12-12 13:15:10' WHERE storedetailid = '16319';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16320', '1', '1', '1', '149109', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 13: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 ('20','50235', '149109', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 13:15: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', '149109', '17', '10291', '1', '73', '73', '0', '', '1', '2024-12-12 13:15:10', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','73','73','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 79 where clientid = 2923;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 7043, 6095, 6095
                    , 6115, 6095, 6111, 6052.61
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,6095, 6208, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7043, sellCostBuyPrice =sellCostBuyPrice+6095
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6095, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6095, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6111
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6052.61
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+6095
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+6208
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2923, '2024-12-12', 7043, 6095, 6095
                    , 6115, 6095, 6111, 6052.61
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,6095, 6208, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7043, sellCostBuyPrice =sellCostBuyPrice+6095
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6095, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6095, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6111
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6052.61
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+6095
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+6208
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 7043, 6095, 6095
                    , 6115, 6095, 6111, 6052.61, 6095, 6208)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+7043, netSellCostBuyPrice = netSellCostBuyPrice+6095
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+6095
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+6115
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+6095
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+6111
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+6052.61
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+6095
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+6208;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ac407b0254 and sellbillId = 149109 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245754
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10665,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '31' , clientdate = '2024-12-12 13:17:03', userid = '104' WHERE clientid = '10665';
UPDATE client SET  inUse = 0 where clientid = 10665;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10665','1111.00','1080','1','ايصال تحصيل (( قبض من عميل ))','245754', '31', '2024-12-12 13:16:48', '104', 'clientPayedDeptController.php', '   ', '1080', '0', null, '0', null, null,'', '-1','1','1','1080','1','','3126','0');
UPDATE save SET  savecurrentvalue = '16940',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('15860.00','1080', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '245754', '16940', '2024-12-12 13:17:03', '104',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1080', '1080', '2024-12-12', '104', '0', '0', '2024-12-12 13:17:03','اضافة ايصال سداد للعميل هيلانة 33','1','0','-1','0','245754','clientPayedDeptController.php?do=show&id=245754');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121704', '-1', '1080', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1080', 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 ('121704', '12360', '1080', '','0');
UPDATE accountstree SET name = 'هيلانة 33', customName = 'هيلانة 33', customNameEn = 'هيلانة 33', nameEn = 'هيلانة 33', parent = '58', accountNature = '0', theValue = '-1080', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-12-10 15:13:40' WHERE id = '12360';
UPDATE clientdebtchange SET clientid = '10665', clientdebtchangebefore = '1111.000', clientdebtchangeamount = '1080.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245754', clientdebtchangeafter = '31.000', clientdebtchangedate = '2024-12-12 13:16:48', userid = '104', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1080.00',discount='', reciptid='0', dailyentryid = '121704',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1080',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245754';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:47:04";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:17:04", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 13:17:04', '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-12 09:47:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:17:06", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 13:17:06', '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-12 09:47:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:17:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:17:32', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:47:43";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:17:43", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:17:43', '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', 'مندوب', '', '260', '2024-12-12', '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 = '16680',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('16940.00','260', '1', '1', 'إضافة مصروف', '25610', '16680', '2024-12-12 13:17:43', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'مندوب', expensesdetails = '', expensesValue = '260.00', expensesdate = '2024-12-12', 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 = '25610';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:47:44";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:17:44", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:17:44', '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-12 09:47:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:17:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:17:45', '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-12 09:48:13";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 13:18:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 13:18:13', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:48:22";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 13:18:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:18:22', '2', 'addsellBill', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:50:22";
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-12',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-12 09:50:23";
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-12 09:50:31";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 13:20:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 13:20:31', '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-12 09:50:32";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:50:42";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 13:20:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 13:20:42', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:51:01";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 13:21:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 13:21:01', '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-12 09:51:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:21:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 13:21:14', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:51:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:21:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 13:21:31', '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-12 09:52:15";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:22:15", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:22:15', '75', 'addAndRetuen', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ac5bee28b6
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(93,@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-12 13:15:10', '0675ac5bee28b6', '93', '18.00', '1098', '0', '1', '1080.00', '1080', '0', '1080', '1', '2024-12-12 13:22:15', '', '75', '0', 'رباب طارق K120', '2', '1', '3', '79', 'رباب طارق K120', '5' ,'0','','','','','-1','0','0','0','0','0','1080','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1098', userid = '75' WHERE clientid = '93';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('93','18.00','1080','0','اضافة فاتورة مبيعات','149110', '1098', '2024-12-12 13:22:15', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1080', '0', null, '0', null, null,'', '0','1','1','1080','1','2024-12-12 13:15:10','0','0');
UPDATE client SET  inUse = 0 where clientid = 93;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34745;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1440', '149110', '14', '15770', '1', '450', '450', '0', '', '1', '2024-12-12 13:22:16', '15770', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34745-1,','1','1','0','0','450','450','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 = 544868;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15770, '2024-12-12', 450, 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+450, 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-12', 450, 390, 390
                    , 390, 390, 390, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0, 390, 390, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, 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 = '5', userid = '75', storedetaildate = '2024-12-12 13:22:16' WHERE storedetailid = '15769';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15770', '1', '1', '1', '149110', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-12 13:22:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35800;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07134', '149110', '5', '16160', '2', '300', '600', '0', '', '1', '2024-12-12 13:22:16', '16160', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35800-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 = 544869;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16160, '2024-12-12', 600, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 600, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '75', storedetaildate = '2024-12-12 13:22:16' WHERE storedetailid = '16159';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16160', '1', '2', '1', '149110', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '13', '75', '2024-12-12 13:22: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', '149110', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 13:22: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', '149110', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-12 13:22:16', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','10','10','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 79 where clientid = 93;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1080, 870, 870
                    , 870, 870, 870, 870
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,870, 870, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1080, sellCostBuyPrice =sellCostBuyPrice+870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+870, sellCostMeanBuyPrice = sellCostMeanBuyPrice+870
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+870
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+870
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+870
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (93, '2024-12-12', 1080, 870, 870
                    , 870, 870, 870, 870
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,870, 870, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1080, sellCostBuyPrice =sellCostBuyPrice+870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+870, sellCostMeanBuyPrice = sellCostMeanBuyPrice+870
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+870
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+870
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+870
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1080, 870, 870
                    , 870, 870, 870, 870, 870, 870)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1080, netSellCostBuyPrice = netSellCostBuyPrice+870
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+870
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+870
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+870
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+870
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+870
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+870
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+870;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ac5bee28b6 and sellbillId = 149110 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:52:16";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:22:16", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:22:16', '75', 'addsellBill', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:52:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:22:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 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 userid = 2;
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 ('ام يوسف 73' , '', '', '01005021117', '0', '', '0', '2024-12-12 13:24:16', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-12','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10680', '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 ('10680','0','0','0','إضافة عميل جديد','10680', '0', '2024-12-12 13:24:16', '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 ('ام يوسف 73', 'ام يوسف 73', 'ام يوسف 73', 'ام يوسف 73', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-12 13:24:16');
UPDATE client SET clientname = 'ام يوسف 73', clientaddress = '', clientphone = '', clientmobile = '01005021117', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-12', 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='12415',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10680';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:55:07";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:25:07", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:25:07', '75', 'addAndRetuen', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ac768dc3d6
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10680,@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-12 13:22:16', '0675ac768dc3d6', '10680', '0.00', '434', '0', '1', '434.00', '434', '0', '434', '1', '2024-12-12 13:25:07', '', '75', '0', 'ام يوسف 73', '2', '1', '3', '79', 'ام يوسف 73', '3' ,'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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '434', userid = '75' WHERE clientid = '10680';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10680','0.00','434','0','اضافة فاتورة مبيعات','149111', '434', '2024-12-12 13:25:07', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '434', '0', null, '0', null, null,'', '0','1','1','434','1','2024-12-12 13:22:16','0','0');
UPDATE client SET  inUse = 0 where clientid = 10680;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35907;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149111', '14', '16167', '1', '410', '410', '0', '', '1', '2024-12-12 13:25:07', '16167', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35907-1,','1','1','0','0','410','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 348.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 348.00
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 347, lastbuyprice_withDiscountAndTax = 350
                where sellbilldetailid = 544872;
 INSERT INTO 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-12', 410, 350, 350
                    , 348, 350, 348, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 350, 347, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+348
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+348
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+347
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 410, 350, 350
                    , 348, 350, 348, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 347, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+348
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+348
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+347
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 13:25: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', '149111', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-12 13:25: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', '149111', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 13:25: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', '149111', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-12 13:25: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 = 79 where clientid = 10680;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 434, 350, 350
                    , 348, 350, 348, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 347, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+434, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+348
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+348
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+347
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10680, '2024-12-12', 434, 350, 350
                    , 348, 350, 348, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,350, 347, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+434, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+348
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+348
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+347
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 350, 350
                    , 348, 350, 348, 345, 350, 347)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+434, netSellCostBuyPrice = netSellCostBuyPrice+350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+350
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+348
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+350
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+348
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+345
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+350
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+347;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ac768dc3d6 and sellbillId = 149111 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

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-12 13:22:32', '0675ac778cf997', '1', '0.00', '0', '0', '1', '125.00', '125', '125', '0', '1', '2024-12-12 13:25:33', '', '104', '0', 'نقدي', '1', '0', '3', '93', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','125','0','','0','0','125','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149112', '0', '2024-12-12 13:25:33', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '125', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 13:22: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 ('215','0K667', '149112', '7', '11475', '1', '125', '125', '0', '', '1', '2024-12-12 13:25:33', '11475', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','125','125','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 215.00 , meanbuyprice = 215.00, lastbuyprice_withDiscount = 215.00, meanbuyprice_withDiscount = 215.00
        
                where sellbilldetailid = 544875;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11475, '2024-12-12', 125, 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+125, 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-12', 125, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, 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 = '104', storedetaildate = '2024-12-12 13:25:33' WHERE storedetailid = '11474';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11475', '1', '1', '1', '149112', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-12 13:25:33','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '16805',  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 ('16680','125', '0', '1', 'اضافة فاتورة مبيعات', '149112', '16805', '2024-12-12 13:25:33', '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-12', 125, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, 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;
 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-12', 125, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+125, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 125, 215, 215
                    , 215, 215, 215, 215, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+125, netSellCostBuyPrice = netSellCostBuyPrice+215
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+215
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+215
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+215
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+215
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+215
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ac778cf997 and sellbillId = 149112 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:55:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:25:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:25: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-12 09:57:39";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 13:27:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 13:27:39', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:57:40";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 13:27:40", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 13:27:40', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:57:53";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 13:27:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 13:27:53', '2', 'add', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =698
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(698,@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 ('698','0.00','150','0','تسوية عجز عميل بالزيادة','-1', '150', '2024-12-12 13:27:53', '2', 'clientDeficitController.php', '', '150', '0', null, '0', null, null,'', '0','1','1','150','1','','0','0');
UPDATE client SET  clientdebt = '150' , clientdate = '2024-12-12', userid = '2' WHERE clientid = '698';
UPDATE client SET  inUse = 0 where clientid = 698;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =698 ,id=245759
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:57:53";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 13:27:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 13:27:53', '2', 'sucess', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:57:55";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 13:27:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 13:27:55', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE userid = 75;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:58:53";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:28:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 13:28:53', '2', '', '192.168.1.16', '', '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-12 09:58:54";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:58:56";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:28:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 13:28:56', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:59:35";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:29:35", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 13:29:35', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245760
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 09:59:36";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:29:36", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 13:29:36', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:00:44";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:30:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 13:30:44', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245761
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245762
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10087,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '1508' , clientdate = '2024-12-12 13:31:10', userid = '2' WHERE clientid = '10087';
UPDATE client SET  inUse = 0 where clientid = 10087;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10087','1841.00','333','1','ايصال تحصيل (( قبض من عميل ))','245762', '1508', '2024-12-12 13:30:45', '2', 'clientPayedDeptController.php', '   ', '333', '0', null, '0', null, null,'', '-1','1','1','333','1','','3129','0');
UPDATE save SET  savecurrentvalue = '456131.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('455798.50','333', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245762', '456131.5', '2024-12-12 13:31:10', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '333', '333', '2024-12-12', '2', '0', '0', '2024-12-12 13:31:11','اضافة ايصال سداد للعميل امل عبد الباقي','1','0','0','0','245762','clientPayedDeptController.php?do=show&id=245762');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121707', '-1', '333', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '333', 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 ('121707', '-1', '333', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-333', 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 = '10087', clientdebtchangebefore = '1841.000', clientdebtchangeamount = '333.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245762', clientdebtchangeafter = '1508.000', clientdebtchangedate = '2024-12-12 13:30:45', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '333.00',discount='', reciptid='0', dailyentryid = '121707',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='333',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245762';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245763
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:01:32";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 13:31:32", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 13:31:32', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:04:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:34:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:34:41', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:04:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:34:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:34:49', '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-12', '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 = '16755',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('16805.00','50', '1', '1', 'إضافة مصروف', '25611', '16755', '2024-12-12 13:34:49', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'يوسف لاحا', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25611';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:04:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:34:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:34:49', '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-12 10:04:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:34:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 13:34:51', '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-12 10:05:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:35:02", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:35: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-12 10:05:58";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:35:58", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 13:35:58', '104', 'all', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=all');
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-12 10:06:16";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:36:16", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 13:36:16', '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-12 10:06:17";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:06:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:36:31", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:36:31', '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-12 10:11:41";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 13:41:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 13:41:41', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:11:50";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 13:41:50", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 13:41:50', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:14:53";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:44:53", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:44:53', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675acabf4edcb
-- ----------------------------------------------------------------------------------------------------

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-12 13:36:31', '0675acabf4edcb', '1', '0.00', '0', '0', '1', '550.00', '550', '550', '0', '1', '2024-12-12 13:44:53', '', '9', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149113', '0', '2024-12-12 13:44:53', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '550', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 13:36:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35480;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1421', '149113', '14', '15749', '1', '550', '550', '0', '', '1', '2024-12-12 13:44:53', '15749', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35480-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 = 544876;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15749, '2024-12-12', 550, 455, 455
                    , 455, 455, 455, 453.75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+455
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+455, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+455, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+453.75
                            , 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-12', 550, 455, 455
                    , 455, 455, 455, 453.75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+455
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+455, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+455, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+453.75
                            , 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 = '5', userid = '9', storedetaildate = '2024-12-12 13:44:53' WHERE storedetailid = '15748';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15749', '1', '1', '1', '149113', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '9', '2024-12-12 13:44:53','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '17305',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('16755','550', '0', '1', 'اضافة فاتورة مبيعات', '149113', '17305', '2024-12-12 13:44:53', '9',  '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-12', 550, 455, 455
                    , 455, 455, 455, 453.75
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+455
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+455, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+455, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+453.75
                            , 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;
 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-12', 550, 455, 455
                    , 455, 455, 455, 453.75
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+455
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+455, sellCostMeanBuyPrice = sellCostMeanBuyPrice+455
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+455, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+455
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+453.75
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 550, 455, 455
                    , 455, 455, 455, 453.75, 455, 455)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+550, netSellCostBuyPrice = netSellCostBuyPrice+455
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+455
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+455
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+455
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+455
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+453.75
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+455
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+455;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675acabf4edcb and sellbillId = 149113 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:14:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:44:54", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:44:54', '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-12 10:16:41";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 13:46:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 13:46:41', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:16:44";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 13:46:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:46:44', '2', 'showDetail', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=148930');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:16:48";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 13:46:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 13:46:48', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:17:16";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 13:47:16", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:47: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 0675ac44c51bdb
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4190,@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-12 13:09:00', '0675ac44c51bdb', '4190', '-4.00', '1516', '0', '1', '1520.00', '1520', '0', '1520', '1', '2024-12-12 13:47:16', '', '75', '0', 'احمد حنفي اسوان i228', '2', '1', '3', '87', 'احمد حنفي اسوان i228', '7' ,'0','','','','','-1','0','0','0','0','0','1520','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1516', userid = '75' WHERE clientid = '4190';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4190','-4.00','1520','0','اضافة فاتورة مبيعات','149114', '1516', '2024-12-12 13:47:16', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1520', '0', null, '0', null, null,'', '0','1','1','1520','1','2024-12-12 13:09:00','0','0');
UPDATE client SET  inUse = 0 where clientid = 4190;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06602', '149114', '5', '15037', '1', '515', '515', '0', '', '1', '2024-12-12 13:47:16', '15037', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','515','515','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 520.00 , meanbuyprice = 509.00, lastbuyprice_withDiscount = 520.00, meanbuyprice_withDiscount = 509.00
        
                where sellbilldetailid = 544877;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15037, '2024-12-12', 515, 520, 520
                    , 509, 520, 509, 507.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+515, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+509
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+509
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+507.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-12', 515, 520, 520
                    , 509, 520, 509, 507.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+515, sellCostBuyPrice =sellCostBuyPrice+520
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+520, sellCostMeanBuyPrice = sellCostMeanBuyPrice+509
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+520, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+509
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+507.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-12 13:47:16' WHERE storedetailid = '15036';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15037', '1', '1', '1', '149114', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-12 13:47:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36004;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149114', '5', '15970', '1', '200', '200', '0', '', '1', '2024-12-12 13:47:16', '15970', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36004-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 = 128, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 544878;
 INSERT INTO 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-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 13:47:16' WHERE storedetailid = '15969';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15970', '1', '1', '1', '149114', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-3', '-4', '75', '2024-12-12 13:47:16','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', '149114', '5', '13491', '1', '300', '300', '0', '', '1', '2024-12-12 13:47:16', '13491', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30100-1,','1','1','0','0','300','300','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 = 544879;
 INSERT INTO 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-12', 300, 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+300, 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-12', 300, 380, 380
                    , 380, 380, 380, 380
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-12 13:47:16' WHERE storedetailid = '13490';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13491', '1', '1', '1', '149114', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 13:47:16','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', '149114', '5', '15119', '1', '235', '235', '0', '', '1', '2024-12-12 13:47:16', '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 = 544880;
 INSERT INTO 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-12', 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-12', 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 = '6', userid = '75', storedetaildate = '2024-12-12 13:47:16' WHERE storedetailid = '15118';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15119', '1', '1', '1', '149114', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-12 13:47:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 28612;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','05764', '149114', '5', '12614', '1', '235', '235', '0', '', '1', '2024-12-12 13:47:16', '12614', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','28612-1,','1','1','0','0','235','235','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
        
                where sellbilldetailid = 544881;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12614, '2024-12-12', 235, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 235, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+235, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-12 13:47:16' WHERE storedetailid = '12613';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12614', '1', '1', '1', '149114', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 13:47: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', '149114', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 13:47: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', '149114', '17', '10291', '1', '15', '15', '0', '', '1', '2024-12-12 13:47:16', '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 = 87 where clientid = 4190;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1520, 1720, 1720
                    , 1709, 1720, 1709, 1708.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 128, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1520, sellCostBuyPrice =sellCostBuyPrice+1720
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1720, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1709
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1720, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1709
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1708.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4190, '2024-12-12', 1520, 1720, 1720
                    , 1709, 1720, 1709, 1708.12
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 128, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1520, sellCostBuyPrice =sellCostBuyPrice+1720
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1720, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1709
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1720, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1709
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1708.12
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1520, 1720, 1720
                    , 1709, 1720, 1709, 1708.12, 140, 128)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1520, netSellCostBuyPrice = netSellCostBuyPrice+1720
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1720
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1709
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1720
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1709
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1708.12
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+140
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+128;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ac44c51bdb and sellbillId = 149114 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:17:17";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 13:47:17", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:47:17', '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-12 10:17:51";
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-12 10:18:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:48:02", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 13:48:02', '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-12 10:18:03";
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-12 10:18:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:48:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 13:48:18', '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-12 10:18:19";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:18:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:48:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:48: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-12 10:18:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 13:48:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 13:48: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 0675acd8569f37
-- ----------------------------------------------------------------------------------------------------

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-12 13:48:21', '0675acd8569f37', '1', '0.00', '0', '0', '1', '250.00', '250', '250', '0', '1', '2024-12-12 13:48:50', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','250','0','','0','0','250','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149115', '0', '2024-12-12 13:48:50', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '250', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 13:48:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35501;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06911', '149115', '5', '15755', '1', '250', '250', '0', '', '1', '2024-12-12 13:48:50', '15755', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35501-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 = 544884;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15755, '2024-12-12', 250, 185, 185
                    , 185, 185, 185, 183
                    , 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+183
                            , 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-12', 250, 185, 185
                    , 185, 185, 185, 183
                    , 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+183
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+185
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+185
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '25', userid = '104', storedetaildate = '2024-12-12 13:48:50' WHERE storedetailid = '15754';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15755', '1', '1', '1', '149115', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '104', '2024-12-12 13:48:50','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '17555',  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 ('17305','250', '0', '1', 'اضافة فاتورة مبيعات', '149115', '17555', '2024-12-12 13:48: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-12', 250, 185, 185
                    , 185, 185, 185, 183
                    , 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+183
                            , 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 (1, '2024-12-12', 250, 185, 185
                    , 185, 185, 185, 183
                    , 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+183
                            , 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, 250, 185, 185
                    , 185, 185, 185, 183, 185, 185)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+250, netSellCostBuyPrice = netSellCostBuyPrice+185
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+185
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+185
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+185
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+185
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+183
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+185
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+185;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675acd8569f37 and sellbillId = 149115 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675acd4553599
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7529,@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-12 13:47:17', '0675acd4553599', '7529', '0.00', '535', '0', '1', '535.00', '535', '0', '535', '1', '2024-12-12 13:48:57', '', '75', '0', 'رحمة السعيد U160', '2', '1', '3', '91', 'رحمة السعيد U160', '4' ,'0','','','','','-1','0','0','0','0','0','535','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '535', userid = '75' WHERE clientid = '7529';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7529','0.00','535','0','اضافة فاتورة مبيعات','149116', '535', '2024-12-12 13:48:57', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '535', '0', null, '0', null, null,'', '0','1','1','535','1','2024-12-12 13:47:17','0','0');
UPDATE client SET  inUse = 0 where clientid = 7529;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35430;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07041', '149116', '5', '16019', '1', '310', '310', '0', '', '1', '2024-12-12 13:48:57', '16019', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35430-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 = 195, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 544885;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16019, '2024-12-12', 310, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 195, 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+195
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 310, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 195, 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+195
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 13:48:57' WHERE storedetailid = '16018';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16019', '1', '1', '1', '149116', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-12 13:48:57','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', '149116', '5', '16299', '1', '200', '200', '0', '', '1', '2024-12-12 13:48:57', '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 = 544886;
 INSERT INTO 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-12', 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-12', 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 = '8', userid = '75', storedetaildate = '2024-12-12 13:48:57' WHERE storedetailid = '16298';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16299', '1', '1', '1', '149116', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-12 13:48:57','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149116', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 13:48:57', '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', '149116', '17', '10291', '1', '5', '5', '0', '', '1', '2024-12-12 13:48:57', '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 = 91 where clientid = 7529;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 535, 390, 390
                    , 390, 390, 390, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,390, 335, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+535, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+390
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+390
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+335
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7529, '2024-12-12', 535, 390, 390
                    , 390, 390, 390, 390
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,390, 335, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+535, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+390
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+390
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+335
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 390, 390
                    , 390, 390, 390, 390, 390, 335)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+535, netSellCostBuyPrice = netSellCostBuyPrice+390
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+390
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+390
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+390
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+390
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+390
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+390
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+335;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675acd4553599 and sellbillId = 149116 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675acda3a0a1c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10281,@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-12 13:48:51', '0675acda3a0a1c', '10281', '-100.00', '0', '0', '1', '230.00', '230', '130', '100', '1', '2024-12-12 14:01:13', '', '104', '0', 'مارو 41', '1', '1', '3', '21', 'مارو 41', '1' ,'0','','','','','-1','0','0','0','0','0','230','0','','0','0','130','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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 = '10281';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10281','-100.00','100','0','اضافة فاتورة مبيعات','149117', '0', '2024-12-12 14:01:13', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '230', '0', null, '0', null, null,'', '0','1','1','100','1','2024-12-12 13:48:51','0','0');
UPDATE client SET  inUse = 0 where clientid = 10281;
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', '149117', '5', '15569', '1', '230', '230', '0', '', '1', '2024-12-12 14:01:13', '15569', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34594-1,','1','1','0','0','230','230','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 = 544889;
 INSERT INTO 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-12', 230, 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+230, 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-12', 230, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 106, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, 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 = '2', userid = '104', storedetaildate = '2024-12-12 14:01:13' WHERE storedetailid = '15568';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15569', '1', '1', '1', '149117', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '104', '2024-12-12 14:01:13','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '17685',  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 ('17555','130', '0', '1', 'اضافة فاتورة مبيعات', '149117', '17685', '2024-12-12 14:01:13', '104',  'sellbillController.php','10281','','0');
UPDATE client SET  delegateid = 21 where clientid = 10281;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 230, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,170, 106, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10281, '2024-12-12', 230, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,170, 106, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 230, 170, 170
                    , 170, 170, 170, 170, 170, 106)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+230, netSellCostBuyPrice = netSellCostBuyPrice+170
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+170
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+170
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+170
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+170
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+170
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+170
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+106;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675acda3a0a1c and sellbillId = 149117 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:31:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:01:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:01: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-12 10:33:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:03:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:03: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 0675ad08a21cb5
-- ----------------------------------------------------------------------------------------------------

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-12 14:01:14', '0675ad08a21cb5', '1', '0.00', '0', '0', '1', '990.00', '990', '990', '0', '1', '2024-12-12 14:03:55', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','990','0','','0','0','990','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149118', '0', '2024-12-12 14:03:55', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '990', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 14:01: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 ('425','05408', '149118', '5', '11785', '2', '295', '590', '0', '', '1', '2024-12-12 14:03:55', '11785', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','295','590','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 425.00 , meanbuyprice = 470.00, lastbuyprice_withDiscount = 425.00, meanbuyprice_withDiscount = 470.00
        
                where sellbilldetailid = 544890;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11785, '2024-12-12', 590, 850, 850
                    , 940, 850, 940, 850
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+590, sellCostBuyPrice =sellCostBuyPrice+850
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+850, sellCostMeanBuyPrice = sellCostMeanBuyPrice+940
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+850, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+940
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+850
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-12', 590, 850, 850
                    , 940, 850, 940, 850
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+590, sellCostBuyPrice =sellCostBuyPrice+850
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+850, sellCostMeanBuyPrice = sellCostMeanBuyPrice+940
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+850, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+940
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+850
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 14:03:55' WHERE storedetailid = '11784';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11785', '1', '2', '1', '149118', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '5', '104', '2024-12-12 14:03:55','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35954;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07120', '149118', '5', '16123', '1', '200', '200', '0', '', '1', '2024-12-12 14:03:55', '16123', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35954-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 = 544891;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16123, '2024-12-12', 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-12', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '104', storedetaildate = '2024-12-12 14:03:55' WHERE storedetailid = '16122';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16123', '1', '1', '1', '149118', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-12 14:03:55','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35899;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149118', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-12 14:03:55', '16293', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35899-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 = 544892;
 INSERT INTO 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-12', 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-12', 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 = '104', storedetaildate = '2024-12-12 14:03:55' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '149118', 'اضافة فاتورة مبيعات', 'sellbillController.php', '38', '37', '104', '2024-12-12 14:03:55','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '18675',  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 ('17685','990', '0', '1', 'اضافة فاتورة مبيعات', '149118', '18675', '2024-12-12 14:03:55', '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-12', 990, 1145, 1145
                    , 1235, 1145, 1235, 1145
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+990, sellCostBuyPrice =sellCostBuyPrice+1145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 990, 1145, 1145
                    , 1235, 1145, 1235, 1145
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+990, sellCostBuyPrice =sellCostBuyPrice+1145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 990, 1145, 1145
                    , 1235, 1145, 1235, 1145, 295, 295)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+990, netSellCostBuyPrice = netSellCostBuyPrice+1145
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1145
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1235
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1145
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1235
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1145
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+295
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+295;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ad08a21cb5 and sellbillId = 149118 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:33:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:03:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:03: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-12 10:34:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:04:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 14:04:10', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:34:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:04:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 14:04:20', '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', 'كريم هادي', '', '150', '2024-12-12', '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 = '18525',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('18675.00','150', '1', '1', 'إضافة مصروف', '25612', '18525', '2024-12-12 14:04:20', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كريم هادي', expensesdetails = '', expensesValue = '150.00', expensesdate = '2024-12-12', 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 = '25612';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:34:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:04:20", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 14:04: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-12 10:34:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:04:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 14:04:22', '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-12 10:36:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:06:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 14:06: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-12 10:36:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:06:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 14:06:31', '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-12 10:36:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:06:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:06:57', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:37:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:07:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:07:50', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245770
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:37:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:07:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:07:51', '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-12 10:37:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:07:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:07:52', '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-12 10:37:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:07:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:07: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-12 10:39:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:09:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:09: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 0675ad21bb42d0
-- ----------------------------------------------------------------------------------------------------

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-12 14:07:55', '0675ad21bb42d0', '1', '0.00', '0', '0', '1', '910.00', '910', '910', '0', '1', '2024-12-12 14:09:23', '', '104', '0', 'نقدي', '1', '0', '3', '54', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','910','0','','0','0','910','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149119', '0', '2024-12-12 14:09:23', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '910', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 14:07:55','0','0');
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', '149119', '5', '16262', '1', '290', '290', '0', '', '1', '2024-12-12 14:09:23', '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 = 544893;
 INSERT INTO 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-12', 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-12', 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 = '10', userid = '104', storedetaildate = '2024-12-12 14:09:23' WHERE storedetailid = '16261';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16262', '1', '1', '1', '149119', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '104', '2024-12-12 14:09:23','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', '149119', '14', '15474', '1', '620', '620', '0', '', '1', '2024-12-12 14:09:23', '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 = 544894;
 INSERT INTO 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-12', 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-12', 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 = '13', userid = '104', storedetaildate = '2024-12-12 14:09:23' WHERE storedetailid = '15473';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15474', '1', '1', '1', '149119', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '104', '2024-12-12 14:09:23','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20175',  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 ('19265','910', '0', '1', 'اضافة فاتورة مبيعات', '149119', '20175', '2024-12-12 14:09:23', '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-12', 910, 735, 735
                    , 735, 735, 735, 735
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,735, 697, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+910, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+735
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+735
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+735
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+697
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 910, 735, 735
                    , 735, 735, 735, 735
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,735, 697, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+910, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+735
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+735
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+735
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+697
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 910, 735, 735
                    , 735, 735, 735, 735, 735, 697)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+910, netSellCostBuyPrice = netSellCostBuyPrice+735
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+735
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+735
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+735
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+735
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+735
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+735
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+697;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ad21bb42d0 and sellbillId = 149119 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245764
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245764 -clientdebtchangeId = 245772
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:40:55";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 14:10:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:10:55', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:41:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:11:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 14:11:15', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:41:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:11:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 14:11:23', '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-12 10:41:29";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 14:11:29", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:11:29', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245773
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245774
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:43:12";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 14:13:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:13:12', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:44:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:14:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:14: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 0675ad2747b48d
-- ----------------------------------------------------------------------------------------------------

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-12 14:09:24', '0675ad2747b48d', '1', '0.00', '0', '0', '1', '200.00', '200', '200', '0', '1', '2024-12-12 14:14:25', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','200','0','','0','0','200','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149120', '0', '2024-12-12 14:14:25', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 14:09:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36004;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149120', '5', '15970', '1', '200', '200', '0', '', '1', '2024-12-12 14:14:25', '15970', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36004-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 = 128, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 544895;
 INSERT INTO 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-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 14:14:25' WHERE storedetailid = '15969';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15970', '1', '1', '1', '149120', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-4', '-5', '104', '2024-12-12 14:14:25','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20375',  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 ('20175','200', '0', '1', 'اضافة فاتورة مبيعات', '149120', '20375', '2024-12-12 14:14: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-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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.62, 140, 128)
                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.62
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+140
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+128;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ad2747b48d and sellbillId = 149120 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:44:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:14:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:14:26', '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-12 10:44:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:14:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:14:30', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid,taxnumber,password,clientTypeForTree,treeId,husbandNameObgy,txtNameE,facility,delegate,txtemail,commercial,valtaxnumber,clientaddress2,country,delegateid,datecustomeraccount) VALUES ('يوسف ايهاب 25' , '', '', '01222746175', '0', '', '0', '2024-12-12 14:15:40', '104', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-12','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10681', '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 ('10681','0','0','0','إضافة عميل جديد','10681', '0', '2024-12-12 14:15: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 ('يوسف ايهاب 25', 'يوسف ايهاب 25', 'يوسف ايهاب 25', 'يوسف ايهاب 25', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '104', '0', '2024-12-12 14:15:40');
UPDATE client SET clientname = 'يوسف ايهاب 25', clientaddress = '', clientphone = '', clientmobile = '01222746175', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-12', 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='12417',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10681';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:45:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:15:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:15:56', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245776
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245776 -clientdebtchangeId = 245777
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:45:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:15:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:15:57', '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-12 10:45:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:15:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:15:59', '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-12 10:45:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:15:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:15: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-12 10:46:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:16:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:16: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-12 10:46:35";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:16:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:16: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-12 10:49:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:19:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:19: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 0675ad3ffb62fe
-- ----------------------------------------------------------------------------------------------------

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-12 14:15:59', '0675ad3ffb62fe', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-12 14:19:47', '', '104', '0', 'نقدي', '1', '0', '3', '71', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149121', '0', '2024-12-12 14:19:47', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 14:15:59','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', '149121', '5', '16369', '1', '300', '300', '0', '', '1', '2024-12-12 14:19:47', '16369', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36095-1,','1','1','0','0','300','300','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 = 544896;
 INSERT INTO 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-12', 300, 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+300, 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-12', 300, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, 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 = '14', userid = '104', storedetaildate = '2024-12-12 14:19:47' WHERE storedetailid = '16368';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16369', '1', '1', '1', '149121', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-12 14:19:47','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20875',  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 ('20575','300', '0', '1', 'اضافة فاتورة مبيعات', '149121', '20875', '2024-12-12 14:19:47', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 71 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-12', 300, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, 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;
 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-12', 300, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 300, 210, 210
                    , 210, 210, 210, 210, 210, 210)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, netSellCostBuyPrice = netSellCostBuyPrice+210
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+210
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+210
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+210
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+210
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+210
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+210;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ad3ffb62fe and sellbillId = 149121 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:49:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:19:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:19: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-12 10:56:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:26:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:26: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 0675ad4240802a
-- ----------------------------------------------------------------------------------------------------

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-12 14:16:36', '0675ad4240802a', '1', '0.00', '0', '0', '1', '530.00', '530', '530', '0', '1', '2024-12-12 14:26:46', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','530','0','','0','0','530','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149122', '0', '2024-12-12 14:26:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '530', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 14:16:36','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', '149122', '5', '15826', '1', '530', '530', '0', '', '1', '2024-12-12 14:26:46', '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 = 544897;
 INSERT INTO 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-12', 530, 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+530, 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-12', 530, 445, 445
                    , 444, 445, 444, 443.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 445, 443, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, 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 = '13', userid = '104', storedetaildate = '2024-12-12 14:26:46' WHERE storedetailid = '15825';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15826', '1', '1', '1', '149122', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '104', '2024-12-12 14:26:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '21405',  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 ('20875','530', '0', '1', 'اضافة فاتورة مبيعات', '149122', '21405', '2024-12-12 14:26:46', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 3 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 530, 445, 445
                    , 444, 445, 444, 443.33
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,445, 443, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, 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;
 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-12', 530, 445, 445
                    , 444, 445, 444, 443.33
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,445, 443, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 530, 445, 445
                    , 444, 445, 444, 443.33, 445, 443)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+530, netSellCostBuyPrice = netSellCostBuyPrice+445
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+445
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+444
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+445
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+444
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+443.33
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+445
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+443;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ad4240802a and sellbillId = 149122 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:56:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:26:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:26: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-12 10:57:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:27:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:27: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 0675ad4e3d553e
-- ----------------------------------------------------------------------------------------------------

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-12 14:19:47', '0675ad4e3d553e', '1', '0.00', '0', '0', '1', '1110.00', '1110', '1110', '0', '1', '2024-12-12 14:27:17', '', '104', '0', 'نقدي', '1', '0', '3', '26', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','1110','0','','0','0','1110','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149123', '0', '2024-12-12 14:27:17', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1110', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 14:19:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35837;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149123', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-12 14:27:17', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35837-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 = 544898;
 INSERT INTO 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-12', 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-12', 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 = '77', userid = '104', storedetaildate = '2024-12-12 14:27:17' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '149123', 'اضافة فاتورة مبيعات', 'sellbillController.php', '78', '77', '104', '2024-12-12 14:27:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35823;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149123', '5', '16239', '1', '300', '300', '0', '', '1', '2024-12-12 14:27:17', '16239', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35823-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 = 544899;
 INSERT INTO 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-12', 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-12', 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 = '28', userid = '104', storedetaildate = '2024-12-12 14:27:17' WHERE storedetailid = '16238';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16239', '1', '1', '1', '149123', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29', '28', '104', '2024-12-12 14:27:17','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22515',  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 ('21405','1110', '0', '1', 'اضافة فاتورة مبيعات', '149123', '22515', '2024-12-12 14:27:17', '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-12', 1110, 970, 970
                    , 970, 970, 970, 970
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,970, 970, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1110, sellCostBuyPrice =sellCostBuyPrice+970
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+970, sellCostMeanBuyPrice = sellCostMeanBuyPrice+970
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+970, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+970
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+970
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+970
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+970
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 1110, 970, 970
                    , 970, 970, 970, 970
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,970, 970, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1110, sellCostBuyPrice =sellCostBuyPrice+970
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+970, sellCostMeanBuyPrice = sellCostMeanBuyPrice+970
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+970, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+970
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+970
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+970
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+970
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1110, 970, 970
                    , 970, 970, 970, 970, 970, 970)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1110, netSellCostBuyPrice = netSellCostBuyPrice+970
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+970
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+970
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+970
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+970
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+970
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+970
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+970;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ad4e3d553e and sellbillId = 149123 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:57:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:27:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:27: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-12 10:58:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:28:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:28: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 0675ad6a6683bb
-- ----------------------------------------------------------------------------------------------------

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-12 14:27:18', '0675ad6a6683bb', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-12 14:28:12', '', '104', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149124', '0', '2024-12-12 14:28:12', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 14:27:18','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', '149124', '5', '16355', '1', '300', '300', '0', '', '1', '2024-12-12 14:28:13', '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 = 544900;
 INSERT INTO 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-12', 300, 250, 250
                    , 245, 250, 245, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 300, 250, 250
                    , 245, 250, 245, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '24', userid = '104', storedetaildate = '2024-12-12 14:28:13' WHERE storedetailid = '16354';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16355', '1', '1', '1', '149124', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '104', '2024-12-12 14:28:13','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22815',  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 ('22515','300', '0', '1', 'اضافة فاتورة مبيعات', '149124', '22815', '2024-12-12 14:28:13', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 300, 250, 250
                    , 245, 250, 245, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,250, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 300, 250, 250
                    , 245, 250, 245, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,250, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 300, 250, 250
                    , 245, 250, 245, 250, 250, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, netSellCostBuyPrice = netSellCostBuyPrice+250
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+250
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+245
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+250
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+245
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+250
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+250
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+240;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ad6a6683bb and sellbillId = 149124 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ad6ddbb3db
-- ----------------------------------------------------------------------------------------------------

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-12 14:28:13', '0675ad6ddbb3db', '1', '0.00', '0', '0', '1', '830.00', '830', '830', '0', '1', '2024-12-12 14:29:20', '', '104', '0', 'نقدي', '1', '0', '3', '25', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','830','0','','0','0','830','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149125', '0', '2024-12-12 14:29:20', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '830', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 14:28: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 ('240','06900', '149125', '5', '15715', '1', '300', '300', '0', '', '1', '2024-12-12 14:29:20', '15715', '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 = 239.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 239.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 238, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 544901;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15715, '2024-12-12', 300, 240, 240
                    , 239, 240, 239, 238.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+239
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+238.33
                            , 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-12', 300, 240, 240
                    , 239, 240, 239, 238.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 238, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+239
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+238.33
                            , 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 = '-5', userid = '104', storedetaildate = '2024-12-12 14:29:20' WHERE storedetailid = '15714';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15715', '1', '1', '1', '149125', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-4', '-5', '104', '2024-12-12 14:29:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 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', '149125', '14', '16312', '1', '530', '530', '0', '', '1', '2024-12-12 14:29:20', '16312', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35953-1,','1','1','0','0','530','530','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 440.00 , meanbuyprice = 440.00, lastbuyprice_withDiscount = 440.00, meanbuyprice_withDiscount = 440.00
        , lastbuyprice_withTax = 440, meanbuyprice_withTax = 440, lastbuyprice_withDiscountAndTax = 440
                where sellbilldetailid = 544902;
 INSERT INTO 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-12', 530, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+440
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 530, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+440
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+440
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '104', storedetaildate = '2024-12-12 14:29:20' WHERE storedetailid = '16311';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16312', '1', '1', '1', '149125', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-12 14:29:20','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '23645',  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 ('22815','830', '0', '1', 'اضافة فاتورة مبيعات', '149125', '23645', '2024-12-12 14:29:20', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 25 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 830, 680, 680
                    , 679, 680, 679, 678.33
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,680, 678, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+830, sellCostBuyPrice =sellCostBuyPrice+680
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+680, sellCostMeanBuyPrice = sellCostMeanBuyPrice+679
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+680, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+679
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+678.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+680
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+678
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 830, 680, 680
                    , 679, 680, 679, 678.33
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,680, 678, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+830, sellCostBuyPrice =sellCostBuyPrice+680
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+680, sellCostMeanBuyPrice = sellCostMeanBuyPrice+679
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+680, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+679
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+678.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+680
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+678
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 830, 680, 680
                    , 679, 680, 679, 678.33, 680, 678)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+830, netSellCostBuyPrice = netSellCostBuyPrice+680
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+680
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+679
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+680
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+679
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+678.33
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+680
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+678;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ad6ddbb3db and sellbillId = 149125 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ad720d9848
-- ----------------------------------------------------------------------------------------------------

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-12 14:29:20', '0675ad720d9848', '1', '0.00', '0', '0', '1', '330.00', '330', '330', '0', '1', '2024-12-12 14:29:58', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','330','0','','0','0','330','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149126', '0', '2024-12-12 14:29:58', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '330', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 14:29:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35957;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149126', '5', '16275', '1', '330', '330', '0', '', '1', '2024-12-12 14:29:58', '16275', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35957-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 = 282, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 544903;
 INSERT INTO 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-12', 330, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 280, 282, 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+282
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 330, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 282, 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+282
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '43', userid = '104', storedetaildate = '2024-12-12 14:29:58' WHERE storedetailid = '16274';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16275', '1', '1', '1', '149126', 'اضافة فاتورة مبيعات', 'sellbillController.php', '44', '43', '104', '2024-12-12 14:29:58','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '23975',  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 ('23645','330', '0', '1', 'اضافة فاتورة مبيعات', '149126', '23975', '2024-12-12 14:29:58', '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-12', 330, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 282, 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+282
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 330, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,280, 282, 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+282
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 330, 280, 280
                    , 281, 280, 281, 280, 280, 282)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+330, netSellCostBuyPrice = netSellCostBuyPrice+280
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+280
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+281
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+280
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+281
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+280
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+280
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+282;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ad720d9848 and sellbillId = 149126 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 10:59:58";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:29:58", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:29: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-12 11:03:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:33:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:33: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 0675ad746ead42
-- ----------------------------------------------------------------------------------------------------

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-12 14:29:58', '0675ad746ead42', '1', '0.00', '0', '0', '1', '620.00', '620', '620', '0', '1', '2024-12-12 14:33:46', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '2' ,'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-12','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','اضافة فاتورة مبيعات','149127', '0', '2024-12-12 14:33:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '620', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 14:29:58','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35927;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07204', '149127', '5', '16303', '1', '320', '320', '0', '', '1', '2024-12-12 14:33:46', '16303', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35927-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 544904;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16303, '2024-12-12', 320, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 320, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '14', userid = '104', storedetaildate = '2024-12-12 14:33:46' WHERE storedetailid = '16302';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16303', '1', '1', '1', '149127', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '104', '2024-12-12 14:33:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35626;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149127', '5', '16170', '1', '300', '300', '0', '', '1', '2024-12-12 14:33:46', '16170', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35626-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 = 544905;
 INSERT INTO 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-12', 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-12', 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 = '18', userid = '104', storedetaildate = '2024-12-12 14:33:46' WHERE storedetailid = '16169';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16170', '1', '1', '1', '149127', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '104', '2024-12-12 14:33:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24595',  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 ('23975','620', '0', '1', 'اضافة فاتورة مبيعات', '149127', '24595', '2024-12-12 14:33:46', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 6 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 620, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,500, 500, 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+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;
 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-12', 620, 500, 500
                    , 500, 500, 500, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,500, 500, 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+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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 620, 500, 500
                    , 500, 500, 500, 500, 500, 500)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+620, netSellCostBuyPrice = netSellCostBuyPrice+500
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+500
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+500
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+500
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+500
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+500
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+500
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+500;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ad746ead42 and sellbillId = 149127 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:03:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:33:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:33: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-12 11:07:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:37:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 14:37:47', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:10:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:40:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 14:40:33', '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-12 11:13:00";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:43:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:43: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-12 11:13:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:43:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:43: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-12 11:13:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:43:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:43: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 0675ada5da2b32
-- ----------------------------------------------------------------------------------------------------

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-12 14:43:09', '0675ada5da2b32', '1', '0.00', '0', '0', '1', '360', '360', '-360', '0', '1', '2024-12-12 14:43:34', '', '104', '0', 'نقدي','1', '0', '5', '74', 'نقدي', '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','اضافة فاتورة مردوات مبيعات','16737', '0', '2024-12-12 14:43:34', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '360', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 14:43: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 ('295.00', '06872', '16737', '5', '15654', '1', '360', '360', '0', '', '1', '0', '15654', '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 = 113.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 113.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 113, lastbuyprice_withDiscountAndTax = 295
                where returnsellbilldetailid = 21897;
 INSERT INTO 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 295, 295, 113
                    , 295, 113, 295, 0, 1, 0, 0, 295, 113)
                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+113, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+295
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+113
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+295
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+295
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+113
                        , 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 295, 295, 113
                    , 295, 113, 295, 0, 0, 295, 113)
                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+113, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+295
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+113
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+295
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+295
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+113;
UPDATE storedetail SET  productquantity = '8', userid = '104', storedetaildate = '2024-12-12 14:43:34' WHERE storedetailid = '15653';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15654', '1', '1', '0', '16737', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '7', '8', '104', '2024-12-12 14:43:34','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24235',  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 ('24595','-360', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16737', '24235', '2024-12-12 14:43:34', '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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 295, 295, 113
                    , 295, 113, 295 ,0, 0, 295, 113)
                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+113, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+295
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+113
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+295
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+295
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+113;
 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 295, 295, 113
                    , 295, 113, 295 ,0, 0, 295, 113)
                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+113, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+295
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+113
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+295
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+295
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+113;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -360, -295, -295
                    , -113, -295, -113, -295, -295, -113)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-360, netSellCostBuyPrice = netSellCostBuyPrice+-295
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-295
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-113
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-295
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-113
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-295
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-295
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-113;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ada5da2b32 and sellbillId = 16737 and returnsellbillId = 16737
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:13:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:43:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:43:34', '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-12 11:13:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:43:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:43: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-12 11:14:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:44:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:44: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 0675ada8e2213e
-- ----------------------------------------------------------------------------------------------------

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-12 14:43:58', '0675ada8e2213e', '1', '0.00', '0', '0', '1', '190.00', '190', '190', '0', '1', '2024-12-12 14:44:33', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149128', '0', '2024-12-12 14:44:33', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '190', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 14:43:58','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34227;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149128', '5', '15165', '1', '190', '190', '0', '', '1', '2024-12-12 14:44:33', '15165', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34227-1,','1','1','0','0','190','190','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 665.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 665.00
        
                where sellbilldetailid = 544906;
 INSERT INTO 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-12', 190, 140, 140
                    , 665, 140, 665, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+665
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+665
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 190, 140, 140
                    , 665, 140, 665, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+665
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+665
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 14:44:33' WHERE storedetailid = '15164';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15165', '1', '1', '1', '149128', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-13', '-14', '104', '2024-12-12 14:44:33','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24425',  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 ('24235','190', '0', '1', 'اضافة فاتورة مبيعات', '149128', '24425', '2024-12-12 14:44:33', '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-12', 190, 140, 140
                    , 665, 140, 665, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+665
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+665
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 190, 140, 140
                    , 665, 140, 665, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+665
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+665
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 190, 140, 140
                    , 665, 140, 665, 140, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+190, netSellCostBuyPrice = netSellCostBuyPrice+140
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+140
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+665
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+140
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+665
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+140
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ada8e2213e and sellbillId = 149128 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:14:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:44:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:44: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-12 11:14:52";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 14:44:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 14:44:53', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:15:07";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 14:45:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 14:45:07', '2', 'add', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =10196
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10196,@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 ('10196','82.00','82','1','تسوية عجز عميل بالخصم','-1', '0', '2024-12-12 14:45:08', '2', 'clientDeficitController.php', '', '82', '0', null, '0', null, null,'', '0','1','1','82','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12', userid = '2' WHERE clientid = '10196';
UPDATE client SET  inUse = 0 where clientid = 10196;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '82', '82', '2024-12-12', '2', '0', '0', '2024-12-12 14:45:08','تم اضافة معالجة عجز للعميل ريهام رمضان 33(تسوية بالخصم)','1','0','0','0','0','');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121714', '398', '82', '','0');
UPDATE accountstree SET name = 'وسام سعيد', customName = 'وسام سعيد', customNameEn = '', nameEn = '', parent = '23', accountNature = '0', theValue = '-40470', theOrder = '0', layingOrder = '', reportid = '2', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '1', sysdate = '0000-00-00 00:00:00' WHERE id = '398';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121714', '10641', '82', '','0');
UPDATE accountstree SET name = 'ريهام رمضان 33', customName = 'ريهام رمضان 33', customNameEn = 'ريهام رمضان 33', nameEn = 'ريهام رمضان 33', parent = '58', accountNature = '0', theValue = '-1803', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-10-25 15:00:51' WHERE id = '10641';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =10196 ,id=245787
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:15:08";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 14:45:08", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 14:45:08', '2', 'sucess', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:15:10";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 14:45:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 14:45:10', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:16:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:46:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 14:46:36', '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-12 11:18:58";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:18:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:48:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:48: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 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-12 11:19:09";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 14:49:09", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 14:49:09', '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-12 11:19:10";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:19:21";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 14:49:21", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:49:21', '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-12 11:19:23";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 14:49:23", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:49: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 0675acdaa2cc71
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2913,@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-12 13:48:58', '0675acdaa2cc71', '2913', '-36.00', '1818', '0', '1', '1854.00', '1854', '0', '1854', '1', '2024-12-12 14:49:24', '', '75', '0', 'اماني محمد بلطيم P8', '2', '1', '3', '78', 'اماني محمد بلطيم P8', '7' ,'0','','','','','-1','0','0','0','0','0','1854','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1818', userid = '75' 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','-36.00','1854','0','اضافة فاتورة مبيعات','149129', '1818', '2024-12-12 14:49:24', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1854', '0', null, '0', null, null,'', '0','1','1','1854','1','2024-12-12 13:48:58','0','0');
UPDATE client SET  inUse = 0 where clientid = 2913;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35915;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('470','H1599', '149129', '14', '16217', '1', '580', '580', '0', '', '1', '2024-12-12 14:49:24', '16217', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35915-1,','1','1','0','0','580','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 470.00 , meanbuyprice = 470.00, lastbuyprice_withDiscount = 470.00, meanbuyprice_withDiscount = 470.00
        , lastbuyprice_withTax = 470, meanbuyprice_withTax = 470, lastbuyprice_withDiscountAndTax = 470
                where sellbilldetailid = 544907;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16217, '2024-12-12', 580, 470, 470
                    , 470, 470, 470, 470
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 470, 470, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+470
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+470, sellCostMeanBuyPrice = sellCostMeanBuyPrice+470
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+470, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+470
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+470
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+470
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+470
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 580, 470, 470
                    , 470, 470, 470, 470
                    , 0, 0, 0, 0
                    , 0, 0, 0, 470, 470, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+470
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+470, sellCostMeanBuyPrice = sellCostMeanBuyPrice+470
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+470, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+470
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+470
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+470
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+470
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '75', storedetaildate = '2024-12-12 14:49:24' WHERE storedetailid = '16216';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16217', '1', '1', '1', '149129', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-12 14:49:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35567;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149129', '5', '15673', '2', '360', '720', '0', '', '1', '2024-12-12 14:49:24', '15673', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35567-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 = 544908;
 INSERT INTO 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-12', 720, 590, 590
                    , 590, 590, 590, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 590, 590, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+590
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+590
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+590
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+590
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+590
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 720, 590, 590
                    , 590, 590, 590, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0, 590, 590, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+590
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+590, sellCostMeanBuyPrice = sellCostMeanBuyPrice+590
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+590, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+590
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+590
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+590
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+590
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '20', userid = '75', storedetaildate = '2024-12-12 14:49: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', '149129', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '20', '75', '2024-12-12 14:49:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31148;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','B1274', '149129', '2', '13996', '1', '205', '205', '0', '', '1', '2024-12-12 14:49:24', '13996', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31148-1,','1','1','0','0','205','205','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
        
                where sellbilldetailid = 544909;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13996, '2024-12-12', 205, 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+205, 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-12', 205, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+205, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+300
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-12 14:49:24' WHERE storedetailid = '13995';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13996', '1', '1', '1', '149129', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-12 14:49: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', '149129', '5', '16321', '1', '310', '310', '0', '', '1', '2024-12-12 14:49: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 = 544910;
 INSERT INTO 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-12', 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-12', 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 = '32', userid = '75', storedetaildate = '2024-12-12 14:49: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', '149129', 'اضافة فاتورة مبيعات', 'sellbillController.php', '33', '32', '75', '2024-12-12 14:49: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', '149129', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 14:49: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', '149129', '17', '10291', '1', '19', '19', '0', '', '1', '2024-12-12 14:49:24', '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 = 78 where clientid = 2913;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1854, 1645, 1645
                    , 1645, 1645, 1645, 1645
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1345, 1345, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1854, sellCostBuyPrice =sellCostBuyPrice+1645
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1645, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1645
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1645, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1645
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1645
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1345
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1345
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2913, '2024-12-12', 1854, 1645, 1645
                    , 1645, 1645, 1645, 1645
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1345, 1345, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1854, sellCostBuyPrice =sellCostBuyPrice+1645
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1645, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1645
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1645, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1645
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1645
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1345
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1345
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1854, 1645, 1645
                    , 1645, 1645, 1645, 1645, 1345, 1345)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1854, netSellCostBuyPrice = netSellCostBuyPrice+1645
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1645
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1645
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1645
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1645
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1645
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1345
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1345;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675acdaa2cc71 and sellbillId = 149129 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:19:25";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 14:49:25", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:49: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-12 11:20:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:50:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 14:50:31', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:20:43";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:50:43", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 14:50:43', '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-12', '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 = '24375',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('24425.00','50', '1', '1', 'إضافة مصروف', '25613', '24375', '2024-12-12 14:50:43', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'محمد عبدة', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25613';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:20:43";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:50:43", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 14:50:43', '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-12 11:20:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 14:50:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 14:50:45', '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-12 11:21:13";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 14:51:13", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:51: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 0675adbd539a3d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1480,@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-12 14:49:25', '0675adbd539a3d', '1480', '14.00', '549', '0', '1', '535.00', '535', '0', '535', '1', '2024-12-12 14:51:13', '', '75', '0', 'ريهام صابر t89', '2', '1', '3', '89', 'ريهام صابر t89', '4' ,'0','','','','','-1','0','0','0','0','0','535','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '549', userid = '75' WHERE clientid = '1480';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1480','14.00','535','0','اضافة فاتورة مبيعات','149130', '549', '2024-12-12 14:51:14', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '535', '0', null, '0', null, null,'', '0','1','1','535','1','2024-12-12 14:49:25','0','0');
UPDATE client SET  inUse = 0 where clientid = 1480;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35920;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149130', '14', '16298', '1', '250', '250', '0', '', '1', '2024-12-12 14:51:14', '16298', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35920-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 = 544913;
 INSERT INTO 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-12', 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-12', 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 = '9', userid = '75', storedetaildate = '2024-12-12 14:51:14' WHERE storedetailid = '16297';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16298', '1', '1', '1', '149130', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-12 14:51:14','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', '149130', '14', '16258', '1', '260', '260', '0', '', '1', '2024-12-12 14:51:14', '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 = 544914;
 INSERT INTO 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-12', 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-12', 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 = '11', userid = '75', storedetaildate = '2024-12-12 14:51:14' WHERE storedetailid = '16257';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16258', '1', '1', '1', '149130', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-12 14:51: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', '149130', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 14:51: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', '149130', '17', '10291', '1', '5', '5', '0', '', '1', '2024-12-12 14:51:14', '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 = 89 where clientid = 1480;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 535, 365, 365
                    , 365, 365, 365, 365
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,365, 365, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+535, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1480, '2024-12-12', 535, 365, 365
                    , 365, 365, 365, 365
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,365, 365, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+535, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 535, 365, 365
                    , 365, 365, 365, 365, 365, 365)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+535, netSellCostBuyPrice = netSellCostBuyPrice+365
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+365
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+365
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+365
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+365
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+365
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+365
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+365;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675adbd539a3d and sellbillId = 149130 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675adbd1a2fba
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(556,@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-12 14:49:21', '0675adbd1a2fba', '556', '3.00', '922', '0', '1', '919.00', '919', '0', '919', '1', '2024-12-12 14:52:34', '', '101', '0', 'ياسمين سليمان k291', '2', '1', '3', '79', 'ياسمين سليمان k291', '6' ,'0','','','','','-1','0','0','0','0','0','919','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '922', userid = '101' WHERE clientid = '556';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('556','3.00','919','0','اضافة فاتورة مبيعات','149131', '922', '2024-12-12 14:52:34', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '919', '0', null, '0', null, null,'', '0','1','1','919','1','2024-12-12 14:49:21','0','0');
UPDATE client SET  inUse = 0 where clientid = 556;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149131', '5', '15165', '1', '190', '190', '0', '', '1', '2024-12-12 14:52:34', '15165', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','190','190','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 665.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 665.00
        
                where sellbilldetailid = 544917;
 INSERT INTO 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-12', 190, 140, 140
                    , 665, 140, 665, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+665
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+665
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 190, 140, 140
                    , 665, 140, 665, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+665
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+665
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 14:52:34' WHERE storedetailid = '15164';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15165', '1', '1', '1', '149131', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-14', '-15', '101', '2024-12-12 14:52:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35600;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07076', '149131', '5', '16068', '1', '200', '200', '0', '', '1', '2024-12-12 14:52:34', '16068', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35600-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 = 544918;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16068, '2024-12-12', 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-12', 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 = '7', userid = '101', storedetaildate = '2024-12-12 14:52:34' WHERE storedetailid = '16067';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16068', '1', '1', '1', '149131', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '101', '2024-12-12 14:52:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35601;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07122', '149131', '5', '16124', '1', '200', '200', '0', '', '1', '2024-12-12 14:52:34', '16124', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35601-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 = 544919;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16124, '2024-12-12', 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-12', 200, 140, 140
                    , 140, 140, 140, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+140, sellCostMeanBuyPrice = sellCostMeanBuyPrice+140
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+140, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+140
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+140
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+140
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '101', storedetaildate = '2024-12-12 14:52:34' WHERE storedetailid = '16123';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16124', '1', '1', '1', '149131', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '101', '2024-12-12 14:52:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35823;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149131', '5', '16239', '1', '300', '300', '0', '', '1', '2024-12-12 14:52:34', '16239', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35823-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 = 544920;
 INSERT INTO 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-12', 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-12', 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 = '27', userid = '101', storedetaildate = '2024-12-12 14:52:34' WHERE storedetailid = '16238';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16239', '1', '1', '1', '149131', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28', '27', '101', '2024-12-12 14:52:34','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149131', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 14:52: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', '149131', '17', '10291', '1', '9', '9', '0', '', '1', '2024-12-12 14:52:35', '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 = 556;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 919, 660, 660
                    , 1185, 660, 1185, 660
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,520, 520, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+919, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+660
                            , 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (556, '2024-12-12', 919, 660, 660
                    , 1185, 660, 1185, 660
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,520, 520, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+919, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1185
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1185
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+660
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 919, 660, 660
                    , 1185, 660, 1185, 660, 520, 520)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+919, netSellCostBuyPrice = netSellCostBuyPrice+660
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+660
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1185
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+660
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1185
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+660
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+520
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+520;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675adbd1a2fba and sellbillId = 149131 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:22:35";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 14:52:35", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:52:35', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:22:48";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 14:52:48", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:52: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 0675adc42eba05
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(207,@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-12 14:51:14', '0675adc42eba05', '207', '0.00', '525', '0', '1', '525.00', '525', '0', '525', '1', '2024-12-12 14:52:48', '', '75', '0', 'شيماء المنصورة t80', '2', '1', '3', '89', 'شيماء المنصورة t80', '4' ,'0','','','','','-1','0','0','0','0','0','525','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '525', userid = '75' WHERE clientid = '207';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('207','0.00','525','0','اضافة فاتورة مبيعات','149132', '525', '2024-12-12 14:52:48', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '525', '0', null, '0', null, null,'', '0','1','1','525','1','2024-12-12 14:51:14','0','0');
UPDATE client SET  inUse = 0 where clientid = 207;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35964;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07214', '149132', '5', '16315', '1', '300', '300', '0', '', '1', '2024-12-12 14:52:48', '16315', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35964-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 = 544923;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16315, '2024-12-12', 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-12', 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 = '12', userid = '75', storedetaildate = '2024-12-12 14:52:48' WHERE storedetailid = '16314';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16315', '1', '1', '1', '149132', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-12 14:52:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36004;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149132', '5', '15970', '1', '200', '200', '0', '', '1', '2024-12-12 14:52:48', '15970', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36004-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 = 128, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 544924;
 INSERT INTO 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-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 14:52:48' WHERE storedetailid = '15969';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15970', '1', '1', '1', '149132', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-5', '-6', '75', '2024-12-12 14:52: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', '149132', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 14:52: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', '149132', '17', '10291', '1', '5', '5', '0', '', '1', '2024-12-12 14:52: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 = 89 where clientid = 207;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 525, 380, 380
                    , 380, 380, 380, 380.62
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,380, 368, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+525, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+368
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (207, '2024-12-12', 525, 380, 380
                    , 380, 380, 380, 380.62
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,380, 368, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+525, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+380.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+368
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 525, 380, 380
                    , 380, 380, 380, 380.62, 380, 368)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+525, netSellCostBuyPrice = netSellCostBuyPrice+380
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+380
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+380
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+380
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+380
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+380.62
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+380
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+368;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675adc42eba05 and sellbillId = 149132 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675adca156932
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4708,@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-12 14:52:49', '0675adca156932', '4708', '0.00', '1525', '0', '1', '1525.00', '1525', '0', '1525', '1', '2024-12-12 14:54:41', '', '75', '0', 'شروق عبد الغني B1424', '2', '1', '3', '78', 'شروق عبد الغني B1424', '5' ,'0','','','','','-1','0','0','0','0','0','1525','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1525', userid = '75' WHERE clientid = '4708';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4708','0.00','1525','0','اضافة فاتورة مبيعات','149133', '1525', '2024-12-12 14:54:41', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1525', '0', null, '0', null, null,'', '0','1','1','1525','1','2024-12-12 14:52:49','0','0');
UPDATE client SET  inUse = 0 where clientid = 4708;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35344;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('620','16014', '149133', '14', '16014', '1', '720', '720', '0', '', '1', '2024-12-12 14:54:41', '16014', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35344-1,','1','1','0','0','720','720','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 620.00 , meanbuyprice = 620.00, lastbuyprice_withDiscount = 620.00, meanbuyprice_withDiscount = 620.00
        , lastbuyprice_withTax = 620, meanbuyprice_withTax = 620, lastbuyprice_withDiscountAndTax = 620
                where sellbilldetailid = 544927;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16014, '2024-12-12', 720, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 620, 620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, 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+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 720, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0, 620, 620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, 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 = '5', userid = '75', storedetaildate = '2024-12-12 14:54:41' WHERE storedetailid = '16013';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16014', '1', '1', '1', '149133', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-12 14:54:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35845;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1617', '149133', '14', '16253', '1', '410', '410', '0', '', '1', '2024-12-12 14:54:41', '16253', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35845-1,','1','1','0','0','410','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 304.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 304.00
        , lastbuyprice_withTax = 300, meanbuyprice_withTax = 302, lastbuyprice_withDiscountAndTax = 300
                where sellbilldetailid = 544928;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16253, '2024-12-12', 410, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+302
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 410, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+302
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 14:54:41' WHERE storedetailid = '16252';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16253', '1', '1', '1', '149133', 'اضافة فاتورة مبيعات', 'sellbillController.php', '42', '41', '75', '2024-12-12 14:54:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35567;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149133', '5', '15673', '1', '360', '360', '0', '', '1', '2024-12-12 14:54:41', '15673', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35567-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 = 544929;
 INSERT INTO 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-12', 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-12', 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 = '19', userid = '75', storedetaildate = '2024-12-12 14:54:41' WHERE storedetailid = '15672';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15673', '1', '1', '1', '149133', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '75', '2024-12-12 14:54:41','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149133', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 14:54:41', '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', '149133', '17', '10291', '1', '15', '15', '0', '', '1', '2024-12-12 14:54:41', '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 = 78 where clientid = 4708;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1525, 1215, 1215
                    , 1219, 1215, 1219, 1216.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1215, 1217, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1525, sellCostBuyPrice =sellCostBuyPrice+1215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1219
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1219
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1216.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1217
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4708, '2024-12-12', 1525, 1215, 1215
                    , 1219, 1215, 1219, 1216.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1215, 1217, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1525, sellCostBuyPrice =sellCostBuyPrice+1215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1219
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1219
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1216.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1217
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1525, 1215, 1215
                    , 1219, 1215, 1219, 1216.5, 1215, 1217)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1525, netSellCostBuyPrice = netSellCostBuyPrice+1215
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1215
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1219
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1215
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1219
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1216.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1215
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1217;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675adca156932 and sellbillId = 149133 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:24:42";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 14:54:42", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:54:42', '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-12 11:25:37";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 14:55:37", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:55: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 0675ac1798d888
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9439,@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-12 12:56:57', '0675ac1798d888', '9439', '0.00', '899', '0', '1', '899.00', '899', '0', '899', '1', '2024-12-12 14:55:37', '', '75', '0', 'فاطمة محمود المنيا k458', '2', '1', '3', '52', 'فاطمة محمود المنيا k458', '3' ,'0','','','','','-1','0','0','0','0','0','899','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '899', userid = '75' WHERE clientid = '9439';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9439','0.00','899','0','اضافة فاتورة مبيعات','149134', '899', '2024-12-12 14:55:37', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '899', '0', null, '0', null, null,'', '0','1','1','899','1','2024-12-12 12:56:57','0','0');
UPDATE client SET  inUse = 0 where clientid = 9439;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35978;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('790','H1627', '149134', '14', '16323', '1', '870', '870', '0', '', '1', '2024-12-12 14:55:37', '16323', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35978-1,','1','1','0','0','870','870','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 790.00 , meanbuyprice = 790.00, lastbuyprice_withDiscount = 790.00, meanbuyprice_withDiscount = 790.00
        , lastbuyprice_withTax = 790, meanbuyprice_withTax = 790, lastbuyprice_withDiscountAndTax = 790
                where sellbilldetailid = 544932;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16323, '2024-12-12', 870, 790, 790
                    , 790, 790, 790, 790
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 790, 790, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+870, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+790
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+790
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+790
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+790
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+790
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 870, 790, 790
                    , 790, 790, 790, 790
                    , 0, 0, 0, 0
                    , 0, 0, 0, 790, 790, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+870, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+790
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+790
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+790
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+790
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+790
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '75', storedetaildate = '2024-12-12 14:55:37' WHERE storedetailid = '16322';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16323', '1', '1', '1', '149134', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-12 14:55: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', '149134', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 14:55: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', '149134', '17', '10291', '1', '9', '9', '0', '', '1', '2024-12-12 14:55:37', '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 = 52 where clientid = 9439;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 899, 790, 790
                    , 790, 790, 790, 790
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,790, 790, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+899, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+790
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+790
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+790
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+790
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+790
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9439, '2024-12-12', 899, 790, 790
                    , 790, 790, 790, 790
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,790, 790, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+899, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+790
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+790
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+790
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+790
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+790
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 899, 790, 790
                    , 790, 790, 790, 790, 790, 790)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+899, netSellCostBuyPrice = netSellCostBuyPrice+790
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+790
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+790
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+790
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+790
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+790
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+790
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+790;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ac1798d888 and sellbillId = 149134 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675adc93c90ef
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3964,@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-12 14:52:35', '0675adc93c90ef', '3964', '0.00', '1303', '0', '1', '1303.00', '1303', '0', '1303', '1', '2024-12-12 14:56:44', '', '101', '0', 'دينا محمد k1005', '2', '1', '3', '79', 'دينا محمد k1005', '8' ,'0','','','','','-1','0','0','0','0','0','1303','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1303', userid = '101' WHERE clientid = '3964';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('3964','0.00','1303','0','اضافة فاتورة مبيعات','149135', '1303', '2024-12-12 14:56:44', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1303', '0', null, '0', null, null,'', '0','1','1','1303','1','2024-12-12 14:52:35','0','0');
UPDATE client SET  inUse = 0 where clientid = 3964;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32367;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06410', '149135', '5', '14578', '1', '160', '160', '0', '', '1', '2024-12-12 14:56:44', '14578', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32367-1,','1','1','0','0','160','160','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 = 544935;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14578, '2024-12-12', 160, 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+160, 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-12', 160, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+160, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '101', storedetaildate = '2024-12-12 14:56:44' WHERE storedetailid = '14577';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14578', '1', '1', '1', '149135', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '101', '2024-12-12 14:56:44','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35645;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06940', '149135', '5', '15821', '1', '200', '200', '0', '', '1', '2024-12-12 14:56:44', '15821', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35645-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 = 132, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 544936;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15821, '2024-12-12', 200, 140, 140
                    , 137, 140, 137, 141.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 132, 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+141.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+132
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 200, 140, 140
                    , 137, 140, 137, 141.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 132, 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+141.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+132
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 14:56:44' WHERE storedetailid = '15820';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15821', '1', '1', '1', '149135', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-7', '-8', '101', '2024-12-12 14:56:44','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('140','07051', '149135', '5', '16247', '2', '200', '400', '0', '', '1', '2024-12-12 14:56:44', '16247', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 544937;
 INSERT INTO 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-12', 400, 280, 400
                    , 340, 400, 340, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , 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+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-12', 400, 280, 400
                    , 340, 400, 340, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , 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 = '-21', userid = '101', storedetaildate = '2024-12-12 14:56:44' WHERE storedetailid = '16246';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16247', '1', '2', '1', '149135', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-19', '-21', '101', '2024-12-12 14:56:44','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35804;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07153', '149135', '5', '16213', '1', '210', '210', '0', '', '1', '2024-12-12 14:56:44', '16213', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35804-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 = 544938;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16213, '2024-12-12', 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-12', 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 = '18', userid = '101', storedetaildate = '2024-12-12 14:56:44' WHERE storedetailid = '16212';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16213', '1', '1', '1', '149135', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '101', '2024-12-12 14:56:44','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('380','06069', '149135', '5', '13551', '1', '300', '300', '0', '', '1', '2024-12-12 14:56:44', '13551', '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 = 380.00 , meanbuyprice = 385.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 385.00
        
                where sellbilldetailid = 544939;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13551, '2024-12-12', 300, 380, 380
                    , 385, 380, 385, 386.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+386.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-12', 300, 380, 380
                    , 385, 380, 385, 386.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+386.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 = '6', userid = '101', storedetaildate = '2024-12-12 14:56:44' WHERE storedetailid = '13550';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13551', '1', '1', '1', '149135', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '101', '2024-12-12 14:56:44','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149135', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 14:56:44', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149135', '17', '10291', '1', '13', '13', '0', '', '1', '2024-12-12 14:56:44', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','13','13','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 79 where clientid = 3964;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1303, 1175, 1295
                    , 1237, 1295, 1237, 1303.34
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,695, 687, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1303, sellCostBuyPrice =sellCostBuyPrice+1175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1237
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1237
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1303.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+695
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+687
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (3964, '2024-12-12', 1303, 1175, 1295
                    , 1237, 1295, 1237, 1303.34
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,695, 687, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1303, sellCostBuyPrice =sellCostBuyPrice+1175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1237
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1237
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1303.34
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+695
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+687
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1303, 1175, 1295
                    , 1237, 1295, 1237, 1303.34, 695, 687)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1303, netSellCostBuyPrice = netSellCostBuyPrice+1175
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1295
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1237
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1295
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1237
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1303.34
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+695
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+687;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675adc93c90ef and sellbillId = 149135 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:26:45";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 14:56:45", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:56:45', '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-12 11:27:21";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 14:57:21", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 14:57:21', '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-12 11:27:21";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:27:25";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 14:57:25", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:57:25', '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-12 11:27:33";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 14:57:33", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:57:33', '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-12 11:28:03";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 14:58:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:58:03', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245775
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245775 -clientdebtchangeId = 245795
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:28:04";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 14:58:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:58:04', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:28:20";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 14:58:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:58:20', '2', 'addsellBill', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:28:24";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 14:58:24", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:58:24', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149135');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:28:25";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 14:58:25", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:58:25', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675add4a301cc
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(95,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-12 14:55:38', '0675add4a301cc', '95', '31.00', '2309', '40', '1', '2318.00', '2278', '0', '2278', '1', '2024-12-12 14:58:26', '', '75', '0', 'سارة شلبي f218', '2', '1', '3', '86', 'سارة شلبي f218', '7' ,'0','','','','','-1','0','0','0','0','0','2278','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2309', userid = '75' WHERE clientid = '95';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('95','31.00','2278','0','اضافة فاتورة مبيعات','149136', '2309', '2024-12-12 14:58:26', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2278', '0', null, '0', null, null,'', '0','1','1','2278','1','2024-12-12 14:55:38','0','0');
UPDATE client SET  inUse = 0 where clientid = 95;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34303;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('650','H1365', '149136', '14', '15506', '1', '870', '870', '0', '', '1', '2024-12-12 14:58:26', '15506', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34303-1,','1','1','0','0','870','870','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 650.00 , meanbuyprice = 650.00, lastbuyprice_withDiscount = 650.00, meanbuyprice_withDiscount = 650.00
        
                where sellbilldetailid = 544942;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15506, '2024-12-12', 854.98705780846, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+854.98705780846, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 854.98705780846, 650, 650
                    , 650, 650, 650, 650
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+854.98705780846, sellCostBuyPrice =sellCostBuyPrice+650
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+650, sellCostMeanBuyPrice = sellCostMeanBuyPrice+650
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+650, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+650
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 14:58:26' WHERE storedetailid = '15505';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15506', '1', '1', '1', '149136', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 14:58:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35881;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('535','H1625', '149136', '14', '16280', '1', '635', '635', '0', '', '1', '2024-12-12 14:58:26', '16280', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35881-1,','1','1','0','0','635','635','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 545.00 , meanbuyprice = 543.00, lastbuyprice_withDiscount = 545.00, meanbuyprice_withDiscount = 543.00
        , lastbuyprice_withTax = 545, meanbuyprice_withTax = 449, lastbuyprice_withDiscountAndTax = 545
                where sellbilldetailid = 544943;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16280, '2024-12-12', 624.04227782571, 545, 545
                    , 543, 545, 543, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 545, 449, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+624.04227782571, sellCostBuyPrice =sellCostBuyPrice+545
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+545, sellCostMeanBuyPrice = sellCostMeanBuyPrice+543
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+545, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+543
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+449
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 624.04227782571, 545, 545
                    , 543, 545, 543, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 545, 449, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+624.04227782571, sellCostBuyPrice =sellCostBuyPrice+545
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+545, sellCostMeanBuyPrice = sellCostMeanBuyPrice+543
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+545, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+543
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+545
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+449
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '21', userid = '75', storedetaildate = '2024-12-12 14:58:26' WHERE storedetailid = '16279';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16280', '1', '1', '1', '149136', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '75', '2024-12-12 14:58:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35611;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07104', '149136', '5', '16116', '2', '280', '560', '0', '', '1', '2024-12-12 14:58:26', '16116', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35611-2,','1','1','0','0','280','560','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 = 544944;
 INSERT INTO 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-12', 550.33649698016, 480, 480
                    , 472, 480, 472, 461.54
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 480, 462, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550.33649698016, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+472
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+472
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+461.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , 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+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-12', 550.33649698016, 480, 480
                    , 472, 480, 472, 461.54
                    , 0, 0, 0, 0
                    , 0, 0, 0, 480, 462, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550.33649698016, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+472
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+472
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+461.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , 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 = '28', userid = '75', storedetaildate = '2024-12-12 14:58:26' WHERE storedetailid = '16115';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16116', '1', '2', '1', '149136', 'اضافة فاتورة مبيعات', 'sellbillController.php', '30', '28', '75', '2024-12-12 14:58:26','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', '149136', '5', '16266', '1', '210', '210', '0', '', '1', '2024-12-12 14:58:26', '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 = 544945;
 INSERT INTO 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-12', 206.37618636756, 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+206.37618636756, 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-12', 206.37618636756, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+206.37618636756, 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 = '14', userid = '75', storedetaildate = '2024-12-12 14:58:26' WHERE storedetailid = '16265';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16266', '1', '1', '1', '149136', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '75', '2024-12-12 14:58:26','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149136', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 14:58:26', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149136', '17', '10291', '1', '23', '23', '0', '', '1', '2024-12-12 14:58:26', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','23','23','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 86 where clientid = 95;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 2278, 1830, 1830
                    , 1820, 1830, 1820, 1806.54
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1180, 1066, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2278, sellCostBuyPrice =sellCostBuyPrice+1830
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1830, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1820
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1830, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1820
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1806.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1180
                            , 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (95, '2024-12-12', 2278, 1830, 1830
                    , 1820, 1830, 1820, 1806.54
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1180, 1066, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2278, sellCostBuyPrice =sellCostBuyPrice+1830
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1830, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1820
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1830, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1820
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1806.54
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1180
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2278, 1830, 1830
                    , 1820, 1830, 1820, 1806.54, 1180, 1066)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2278, netSellCostBuyPrice = netSellCostBuyPrice+1830
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1830
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1820
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1830
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1820
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1806.54
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1180
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1066;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675add4a301cc and sellbillId = 149136 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:28:27";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 14:58:27", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:58:27', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:28:37";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 14:58:37", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 14:58:37', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149131');
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' , '', '', '01225068489', '0', '', '0', '2024-12-12 14:58:43', '2', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-12','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10682', '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 ('10682','0','0','0','إضافة عميل جديد','10682', '0', '2024-12-12 14:58:43', '2', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('ماري مرقص 43', 'ماري مرقص 43', 'ماري مرقص 43', 'ماري مرقص 43', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-12 14:58:43');
UPDATE client SET clientname = 'ماري مرقص 43', clientaddress = '', clientphone = '', clientmobile = '01225068489', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-12', userid = '2'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12418',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10682';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:28:47";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 14:58:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 14:58:47', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:29:14";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 14:59:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:59:14', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245796
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245796 -clientdebtchangeId = 245798
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:29:15";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 14:59:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:59:15', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:29:24";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 14:59:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:59:24', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:29:44";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 14:59:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:59:44', '2', 'remove', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=remove&id=245798&action=121716');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController delete - with clientdebtchangeId =245798
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10682,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '2' WHERE clientid = '10682';
UPDATE client SET  inUse = 0 where clientid = 10682;
UPDATE clientdebtchange SET del='1' WHERE clientdebtchangeid = '245798';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid, del,dailyentryid , num , billid ,paytype,seller,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments) VALUES ('10682','-200.00','200.000','0','الغاء سداد ديون عميل','245798', '0', '2024-12-12 14:59:44', '2', 'clientPayedDeptController.php', '', '200', '0', null, '1', '121716', null, null,'','0','1','1','200','1','','0','0');
UPDATE save SET  savecurrentvalue = '457975.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('458175.50','200', '1', '2', 'الغاء سداد ديون عميل', '245799', '457975.5', '2024-12-12 14:59:45', '2',  'clientPayedDeptController.php','0','','0');
UPDATE dailyentry SET totalcreditor = '200.00', totaldebtor = '200.00', thedate = '2024-12-12', userid = '2', `condition` = '0', reverseofid = '-10', dDateTime = '2024-12-12 14:59:14', entryComment = 'اضافة ايصال سداد للعميل ماري مرقص 43', fromFlag = '1',related='0',isopeningentry='0',operationId='245798',operationDetailLink='clientPayedDeptController.php?do=show&id=245798' WHERE id = '121716';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '200.00', '200.00', '2024-12-12', '2', '0', '121716', '2024-12-12 14:59:45','تم عكس القيد رقم 121716 ','1','0','0','0','0','');
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121717', '-1', '200.00', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-200', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121717', '12418', '200.00', '','0');
UPDATE accountstree SET name = 'ماري مرقص 43', customName = 'ماري مرقص 43', customNameEn = 'ماري مرقص 43', nameEn = 'ماري مرقص 43', parent = '58', accountNature = '0', theValue = '0', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-12 14:58:43' WHERE id = '12418';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController delete end - with clientdebtchangeId =245798
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:29:45";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 14:59:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:59:45', '2', 'sucess', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:29:47";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 14:59:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:59:47', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:29:49";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 14:59:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 14:59:49', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:30:10";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 15:00:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 15:00:10', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245800
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245801
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10679,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12 15:00:33', userid = '2' WHERE clientid = '10679';
UPDATE client SET  inUse = 0 where clientid = 10679;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10679','424.00','424','1','ايصال تحصيل (( قبض من عميل ))','245801', '0', '2024-12-12 15:00:11', '2', 'clientPayedDeptController.php', '   ', '424', '0', null, '0', null, null,'', '-1','1','1','424','1','','3137','0');
UPDATE save SET  savecurrentvalue = '458399.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('457975.50','424', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245801', '458399.5', '2024-12-12 15:00:33', '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-12', '2', '0', '0', '2024-12-12 15:00:33','اضافة ايصال سداد للعميل اية عبد العظيم 33','1','0','0','0','245801','clientPayedDeptController.php?do=show&id=245801');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121719', '-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 ('121719', '12410', '424', '','0');
UPDATE accountstree SET name = 'اية عبد العظيم 33', customName = 'اية عبد العظيم 33', customNameEn = 'اية عبد العظيم 33', nameEn = 'اية عبد العظيم 33', 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-12 12:57:38' WHERE id = '12410';
UPDATE clientdebtchange SET clientid = '10679', clientdebtchangebefore = '424.000', clientdebtchangeamount = '424.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245801', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-12 15:00:11', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '424.00',discount='', reciptid='0', dailyentryid = '121719',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='424',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245801';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245802
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9099,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12 15:00:51', userid = '2' WHERE clientid = '9099';
UPDATE client SET  inUse = 0 where clientid = 9099;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9099','434.00','434','1','ايصال تحصيل (( قبض من عميل ))','245802', '0', '2024-12-12 15:00:34', '2', 'clientPayedDeptController.php', '   ', '434', '0', null, '0', null, null,'', '-1','1','1','434','1','','3138','0');
UPDATE save SET  savecurrentvalue = '458833.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('458399.50','434', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245802', '458833.5', '2024-12-12 15:00:51', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '434', '434', '2024-12-12', '2', '0', '0', '2024-12-12 15:00:51','اضافة ايصال سداد للعميل رحمة فودة P519','1','0','0','0','245802','clientPayedDeptController.php?do=show&id=245802');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121720', '-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 ('121720', '-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;
UPDATE clientdebtchange SET clientid = '9099', clientdebtchangebefore = '434.000', clientdebtchangeamount = '434.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245802', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-12 15:00:34', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '434.00',discount='', reciptid='0', dailyentryid = '121720',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='434',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245802';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245803
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675addf3816f7
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10660,@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-12 14:58:27', '0675addf3816f7', '10660', '-200.00', '522', '0', '1', '722.00', '722', '0', '722', '1', '2024-12-12 15:01:36', '', '75', '0', 'سها سمير 41', '2', '1', '3', '87', 'سها سمير 41', '5' ,'0','','','','','-1','0','0','0','0','0','722','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '522', userid = '75' WHERE clientid = '10660';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10660','-200.00','722','0','اضافة فاتورة مبيعات','149137', '522', '2024-12-12 15:01:36', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '722', '0', null, '0', null, null,'', '0','1','1','722','1','2024-12-12 14:58:27','0','0');
UPDATE client SET  inUse = 0 where clientid = 10660;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35927;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07204', '149137', '5', '16303', '1', '320', '320', '0', '', '1', '2024-12-12 15:01:36', '16303', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35927-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 544948;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16303, '2024-12-12', 320, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 320, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '75', storedetaildate = '2024-12-12 15:01:36' WHERE storedetailid = '16302';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16303', '1', '1', '1', '149137', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-12 15:01:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34353;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06822', '149137', '5', '15527', '1', '300', '300', '0', '', '1', '2024-12-12 15:01:36', '15527', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34353-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
        
                where sellbilldetailid = 544949;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15527, '2024-12-12', 300, 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+300, 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-12', 300, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 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+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 15:01:36' WHERE storedetailid = '15526';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15527', '1', '1', '1', '149137', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 15:01:36','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31811;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('80','R2845', '149137', '1', '14189', '1', '75', '75', '0', '', '1', '2024-12-12 15:01:36', '14189', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31811-1,','1','1','0','0','75','75','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 80.00 , meanbuyprice = 80.00, lastbuyprice_withDiscount = 80.00, meanbuyprice_withDiscount = 80.00
        
                where sellbilldetailid = 544950;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14189, '2024-12-12', 75, 80, 80
                    , 80, 80, 80, 80
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+75, sellCostBuyPrice =sellCostBuyPrice+80
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+80, sellCostMeanBuyPrice = sellCostMeanBuyPrice+80
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+80, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+80
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+80
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 75, 80, 80
                    , 80, 80, 80, 80
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+75, sellCostBuyPrice =sellCostBuyPrice+80
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+80, sellCostMeanBuyPrice = sellCostMeanBuyPrice+80
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+80, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+80
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+80
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 15:01:36' WHERE storedetailid = '14188';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14189', '1', '1', '1', '149137', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-12 15:01: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', '149137', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 15:01: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 sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149137', '17', '10291', '1', '7', '7', '0', '', '1', '2024-12-12 15:01:36', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','7','7','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 87 where clientid = 10660;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 722, 580, 580
                    , 580, 580, 580, 580
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+722, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+580
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+580
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+580
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10660, '2024-12-12', 722, 580, 580
                    , 580, 580, 580, 580
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+722, sellCostBuyPrice =sellCostBuyPrice+580
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+580
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+580
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+580
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+250
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 722, 580, 580
                    , 580, 580, 580, 580, 250, 250)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+722, netSellCostBuyPrice = netSellCostBuyPrice+580
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+580
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+580
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+580
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+580
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+580
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+250
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+250;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675addf3816f7 and sellbillId = 149137 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:31:37";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:01:37", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:01:37', '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-12 11:32:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:02:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:02: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-12 11:32:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:02:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:02:51', '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-12', '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 = '24325',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('24375.00','50', '1', '1', 'إضافة مصروف', '25614', '24325', '2024-12-12 15:02:51', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'فريده', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25614';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:32:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:02:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:02:51', '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-12 11:32:53";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:02:53", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:02:53', '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-12 11:33:34";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:03:34", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:03: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 0675adeb1b4440
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1329,@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-12 15:01:37', '0675adeb1b4440', '1329', '0.00', '424', '0', '1', '424.00', '424', '0', '424', '1', '2024-12-12 15:03:34', '', '75', '0', 'مي الادهم Y49', '2', '1', '3', '80', 'مي الادهم Y49', '4' ,'0','','','','','-1','0','0','0','0','0','424','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '424', userid = '75' WHERE clientid = '1329';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1329','0.00','424','0','اضافة فاتورة مبيعات','149138', '424', '2024-12-12 15:03:34', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '424', '0', null, '0', null, null,'', '0','1','1','424','1','2024-12-12 15:01:37','0','0');
UPDATE client SET  inUse = 0 where clientid = 1329;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06845', '149138', '5', '15576', '1', '110', '110', '0', '', '1', '2024-12-12 15:03:34', '15576', '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 = 240.00 , meanbuyprice = 242.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 242.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 242, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 544953;
 INSERT INTO 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-12', 110, 240, 240
                    , 242, 240, 242, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 242, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+110, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+242
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+242
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+242
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 110, 240, 240
                    , 242, 240, 242, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 242, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+110, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+242
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+242
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+242
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 15:03:34' WHERE storedetailid = '15575';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15576', '1', '1', '1', '149138', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-12 15:03:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35882;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('245','R3326', '149138', '1', '16281', '1', '290', '290', '0', '', '1', '2024-12-12 15:03:34', '16281', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35882-1,','1','1','0','0','290','290','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 245.00 , meanbuyprice = 245.00, lastbuyprice_withDiscount = 245.00, meanbuyprice_withDiscount = 245.00
        , lastbuyprice_withTax = 245, meanbuyprice_withTax = 245, lastbuyprice_withDiscountAndTax = 245
                where sellbilldetailid = 544954;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16281, '2024-12-12', 290, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 245, 245, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+245
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 290, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 245, 245, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+245
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+245
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+245
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '6', userid = '75', storedetaildate = '2024-12-12 15:03:34' WHERE storedetailid = '16280';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16281', '1', '1', '1', '149138', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-12 15:03:34','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149138', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 15:03:34', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149138', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-12 15:03:34', '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 = 1329;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 424, 485, 485
                    , 487, 485, 487, 435
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,485, 487, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+424, sellCostBuyPrice =sellCostBuyPrice+485
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+485, sellCostMeanBuyPrice = sellCostMeanBuyPrice+487
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+485, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+487
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+435
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+485
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+487
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1329, '2024-12-12', 424, 485, 485
                    , 487, 485, 487, 435
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,485, 487, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+424, sellCostBuyPrice =sellCostBuyPrice+485
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+485, sellCostMeanBuyPrice = sellCostMeanBuyPrice+487
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+485, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+487
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+435
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+485
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+487
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 424, 485, 485
                    , 487, 485, 487, 435, 485, 487)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+424, netSellCostBuyPrice = netSellCostBuyPrice+485
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+485
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+487
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+485
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+487
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+435
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+485
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+487;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675adeb1b4440 and sellbillId = 149138 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:33:35";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:03:35", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:03: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-12 11:35:42";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:05:42", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 15:05:42', '75', '', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:35:54";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:05:54", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 15:05:54', '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-12 11:35:56";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:05:56", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:05:56', '75', 'showDetail', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149133');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:35:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:05:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:05: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-12 11:36:36";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:06:36", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:06:36', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675adf27bdb7f
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4708,@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-12 15:03:35', '0675adf27bdb7f', '4708', '1525.00', '1682', '0', '1', '157.00', '157', '0', '157', '1', '2024-12-12 15:06:36', '', '75', '0', 'شروق عبد الغني B1424', '2', '1', '3', '78', 'شروق عبد الغني B1424', '2' ,'0','','','','','-1','0','0','0','0','0','157','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1682', userid = '75' WHERE clientid = '4708';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4708','1525.00','157','0','اضافة فاتورة مبيعات','149139', '1682', '2024-12-12 15:06:36', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '157', '0', null, '0', null, null,'', '0','1','1','157','1','2024-12-12 15:03:35','0','0');
UPDATE client SET  inUse = 0 where clientid = 4708;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30195;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2759', '149139', '1', '13536', '1', '155', '155', '0', '', '1', '2024-12-12 15:06:36', '13536', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30195-1,','1','1','0','0','155','155','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
        
                where sellbilldetailid = 544957;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13536, '2024-12-12', 155, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , 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-12', 155, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , 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 = '4', userid = '75', storedetaildate = '2024-12-12 15:06:36' WHERE storedetailid = '13535';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13536', '1', '1', '1', '149139', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 15:06: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 ('0','10291', '149139', '17', '10291', '1', '2', '2', '0', '', '1', '2024-12-12 15:06:36', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','2','2','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 78 where clientid = 4708;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 157, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+157, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4708, '2024-12-12', 157, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+157, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 157, 165, 165
                    , 165, 165, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+157, netSellCostBuyPrice = netSellCostBuyPrice+165
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+165
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+165
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+165
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+165
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+165
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675adf27bdb7f and sellbillId = 149139 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:36:37";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:06:37", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:06:37', '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-12 11:36:54";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:06:54", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:06: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-12 11:42:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:12:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:12: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 0675adab257393
-- ----------------------------------------------------------------------------------------------------

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-12 14:44:34', '0675adab257393', '1', '0.00', '0', '0', '1', '290.00', '290', '290', '0', '1', '2024-12-12 15:12:48', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','290','0','','0','0','290','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149140', '0', '2024-12-12 15:12:48', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '290', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 14:44:34','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35854;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07183', '149140', '5', '16263', '1', '290', '290', '0', '', '1', '2024-12-12 15:12:48', '16263', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35854-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 = 544959;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16263, '2024-12-12', 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-12', 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 = '104', storedetaildate = '2024-12-12 15:12:48' WHERE storedetailid = '16262';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16263', '1', '1', '1', '149140', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '104', '2024-12-12 15:12:48','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24615',  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 ('24325','290', '0', '1', 'اضافة فاتورة مبيعات', '149140', '24615', '2024-12-12 15:12:48', '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-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 290, 235, 235
                    , 235, 235, 235, 235, 235, 235)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+290, 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 0675adab257393 and sellbillId = 149140 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:42:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:12:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:12: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-12 11:43:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:13:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:13: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 0675ae1512a075
-- ----------------------------------------------------------------------------------------------------

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-12 15:12:49', '0675ae1512a075', '1', '0.00', '0', '0', '1', '380.00', '380', '380', '0', '1', '2024-12-12 15:13:51', '', '104', '0', 'نقدي', '1', '0', '3', '54', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','380','0','','0','0','380','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149141', '0', '2024-12-12 15:13:51', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '380', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:12:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35526;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07119', '149141', '5', '16122', '1', '380', '380', '0', '', '1', '2024-12-12 15:13:51', '16122', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35526-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 = 544960;
 INSERT INTO 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-12', 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-12', 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 = '16', userid = '104', storedetaildate = '2024-12-12 15:13:51' WHERE storedetailid = '16121';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16122', '1', '1', '1', '149141', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '104', '2024-12-12 15:13:51','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24995',  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 ('24615','380', '0', '1', 'اضافة فاتورة مبيعات', '149141', '24995', '2024-12-12 15:13:51', '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-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 380, 330, 330
                    , 330, 330, 330, 325, 330, 323)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+380, netSellCostBuyPrice = netSellCostBuyPrice+330
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+330
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+330
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+330
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+330
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+325
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+330
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+323;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ae1512a075 and sellbillId = 149141 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:43:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:13:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:13: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-12 11:44:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:14:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:14: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 0675ae1904f030
-- ----------------------------------------------------------------------------------------------------

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-12 15:13:52', '0675ae1904f030', '1', '0.00', '0', '0', '1', '210.00', '210', '210', '0', '1', '2024-12-12 15:14:28', '', '104', '0', 'نقدي', '1', '0', '3', '95', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149142', '0', '2024-12-12 15:14:28', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '210', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:13:52','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36278;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149142', '5', '15855', '1', '210', '210', '0', '', '1', '2024-12-12 15:14:28', '15855', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36278-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 = 544961;
 INSERT INTO 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-12', 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-12', 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 = '45', userid = '104', storedetaildate = '2024-12-12 15:14:28' WHERE storedetailid = '15854';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15855', '1', '1', '1', '149142', 'اضافة فاتورة مبيعات', 'sellbillController.php', '46', '45', '104', '2024-12-12 15:14:28','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '25205',  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 ('24995','210', '0', '1', 'اضافة فاتورة مبيعات', '149142', '25205', '2024-12-12 15:14:28', '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-12', 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-12', 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 0675ae1904f030 and sellbillId = 149142 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:44:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:14:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:14: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-12 11:44:34";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:14:35", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:14: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-12 11:44:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:14:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:14: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 0675adfb7cb7fc
-- ----------------------------------------------------------------------------------------------------

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-12 15:05:59', '0675adfb7cb7fc', '1', '0.00', '0', '360', '1', '6970.00', '6610', '6610', '0', '1', '2024-12-12 15:14:40', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '18' ,'0','','','','','-1','0','0','0','0','0','6610','0','','0','0','6610','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149143', '0', '2024-12-12 15:14:40', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '6610', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:05:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35597;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35858;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149143', '5', '15995', '2', '480', '960', '0', '', '1', '2024-12-12 15:14:40', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35597-1,35858-1,','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 = 544962;
 INSERT INTO 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-12', 910.41606886657, 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+910.41606886657, 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-12', 910.41606886657, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+910.41606886657, 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 = '109', userid = '104', storedetaildate = '2024-12-12 15:14:40' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '2', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '111', '109', '104', '2024-12-12 15:14:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35957;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149143', '5', '16275', '1', '330', '330', '0', '', '1', '2024-12-12 15:14:40', '16275', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35957-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 = 282, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 544963;
 INSERT INTO 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-12', 312.95552367288, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 280, 282, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+312.95552367288, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+281
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+281
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+282
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 312.95552367288, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 282, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+312.95552367288, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+281
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+281
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+282
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 15:14:40' WHERE storedetailid = '16274';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16275', '1', '1', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '43', '42', '104', '2024-12-12 15:14:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '149143', '5', '16299', '2', '200', '400', '0', '', '1', '2024-12-12 15:14:40', '16299', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35922-2,','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 544964;
 INSERT INTO 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-12', 379.3400286944, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+379.3400286944, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 379.3400286944, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+379.3400286944, 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 = '6', userid = '104', storedetaildate = '2024-12-12 15:14:40' WHERE storedetailid = '16298';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16299', '1', '2', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '6', '104', '2024-12-12 15:14:40','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', '149143', '5', '16355', '1', '300', '300', '0', '', '1', '2024-12-12 15:14:40', '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 = 544965;
 INSERT INTO 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-12', 284.5050215208, 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+284.5050215208, 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-12', 284.5050215208, 250, 250
                    , 245, 250, 245, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+284.5050215208, 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 = '23', userid = '104', storedetaildate = '2024-12-12 15:14:40' WHERE storedetailid = '16354';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16355', '1', '1', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '104', '2024-12-12 15:14:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35660;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07019', '149143', '5', '15985', '1', '230', '230', '0', '', '1', '2024-12-12 15:14:40', '15985', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35660-1,','1','1','0','0','230','230','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 = 544966;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15985, '2024-12-12', 218.12051649928, 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+218.12051649928, 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-12', 218.12051649928, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+218.12051649928, 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 = '-1', userid = '104', storedetaildate = '2024-12-12 15:14:40' WHERE storedetailid = '15984';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15985', '1', '1', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '104', '2024-12-12 15:14:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35823;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149143', '5', '16239', '1', '300', '300', '0', '', '1', '2024-12-12 15:14:40', '16239', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35823-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 = 544967;
 INSERT INTO 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-12', 284.5050215208, 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+284.5050215208, 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-12', 284.5050215208, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+284.5050215208, 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 = '26', userid = '104', storedetaildate = '2024-12-12 15:14:40' WHERE storedetailid = '16238';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16239', '1', '1', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27', '26', '104', '2024-12-12 15:14:40','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', '149143', '14', '16312', '2', '530', '1060', '0', '', '1', '2024-12-12 15:14:40', '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 = 544968;
 INSERT INTO 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-12', 1005.2510760402, 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+1005.2510760402, 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-12', 1005.2510760402, 880, 880
                    , 880, 880, 880, 880
                    , 0, 0, 0, 0
                    , 0, 0, 0, 880, 880, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1005.2510760402, 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 = '12', userid = '104', storedetaildate = '2024-12-12 15:14:40' WHERE storedetailid = '16311';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16312', '1', '2', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '12', '104', '2024-12-12 15:14:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35355;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0K787', '149143', '7', '15764', '1', '300', '300', '0', '', '1', '2024-12-12 15:14:40', '15764', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35355-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 = 220, lastbuyprice_withDiscountAndTax = 230
                where sellbilldetailid = 544969;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15764, '2024-12-12', 284.5050215208, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 230, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+284.5050215208, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , 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-12', 284.5050215208, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+284.5050215208, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+230
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+230
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+230
                            , 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 = '4', userid = '104', storedetaildate = '2024-12-12 15:14:40' WHERE storedetailid = '15763';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15764', '1', '1', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-12 15:14: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 ('270','R2920', '149143', '1', '14395', '1', '330', '330', '0', '', '1', '2024-12-12 15:14:40', '14395', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','330','330','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 270.00 , meanbuyprice = 269.00, lastbuyprice_withDiscount = 270.00, meanbuyprice_withDiscount = 269.00
        
                where sellbilldetailid = 544970;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14395, '2024-12-12', 312.95552367288, 270, 270
                    , 269, 270, 269, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+312.95552367288, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+269
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+269
                            , 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-12', 312.95552367288, 270, 270
                    , 269, 270, 269, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+312.95552367288, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+269
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+269
                            , 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-12 15:14:40' WHERE storedetailid = '14394';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14395', '1', '1', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-12 15:14:40','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', '149143', '5', '16347', '1', '200', '200', '0', '', '1', '2024-12-12 15:14:40', '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 = 544971;
 INSERT INTO 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-12', 189.6700143472, 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+189.6700143472, 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-12', 189.6700143472, 140, 140
                    , 137, 140, 137, 140
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 134, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+189.6700143472, 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 = '22', userid = '104', storedetaildate = '2024-12-12 15:14:40' WHERE storedetailid = '16346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16347', '1', '1', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '104', '2024-12-12 15:14:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35830;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('440','07176', '149143', '5', '16244', '1', '500', '500', '0', '', '1', '2024-12-12 15:14:40', '16244', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35830-1,','1','1','0','0','500','500','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 = 544972;
 INSERT INTO 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-12', 474.17503586801, 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+474.17503586801, 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-12', 474.17503586801, 440, 440
                    , 440, 440, 440, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 440, 440, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+474.17503586801, 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 = '10', userid = '104', storedetaildate = '2024-12-12 15:14:40' WHERE storedetailid = '16243';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16244', '1', '1', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '104', '2024-12-12 15:14:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35800;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07134', '149143', '5', '16160', '1', '300', '300', '0', '', '1', '2024-12-12 15:14:40', '16160', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35800-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 = 544973;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16160, '2024-12-12', 284.5050215208, 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+284.5050215208, 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-12', 284.5050215208, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+284.5050215208, 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 = '12', userid = '104', storedetaildate = '2024-12-12 15:14:40' WHERE storedetailid = '16159';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16160', '1', '1', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '104', '2024-12-12 15:14:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35806;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149143', '5', '16234', '1', '550', '550', '0', '', '1', '2024-12-12 15:14:40', '16234', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35806-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 = 544974;
 INSERT INTO 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-12', 521.59253945481, 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+521.59253945481, 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-12', 521.59253945481, 455, 455
                    , 455, 455, 455, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+521.59253945481, 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 = '38', userid = '104', storedetaildate = '2024-12-12 15:14:40' WHERE storedetailid = '16233';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16234', '1', '1', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '39', '38', '104', '2024-12-12 15:14:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35880;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149143', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-12 15:14:40', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35880-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 = 544975;
 INSERT INTO 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-12', 379.3400286944, 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+379.3400286944, 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-12', 379.3400286944, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 335, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+379.3400286944, 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 = '55', userid = '104', storedetaildate = '2024-12-12 15:14:40' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '56', '55', '104', '2024-12-12 15:14:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35837;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149143', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-12 15:14:41', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35837-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 = 544976;
 INSERT INTO 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-12', 768.16355810617, 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+768.16355810617, 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-12', 768.16355810617, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0, 730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+768.16355810617, 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 = '76', userid = '104', storedetaildate = '2024-12-12 15:14:41' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '149143', 'اضافة فاتورة مبيعات', 'sellbillController.php', '77', '76', '104', '2024-12-12 15:14:41','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '31815',  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 ('25205','6610', '0', '1', 'اضافة فاتورة مبيعات', '149143', '31815', '2024-12-12 15:14:41', '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-12', 6610, 5780, 5780
                    , 5772, 5780, 5772, 5780
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,5510, 5436, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+6610, sellCostBuyPrice =sellCostBuyPrice+5780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+5780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+5772
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+5780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+5772
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+5780
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+5510
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5436
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 6610, 5780, 5780
                    , 5772, 5780, 5772, 5780
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,5510, 5436, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+6610, sellCostBuyPrice =sellCostBuyPrice+5780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+5780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+5772
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+5780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+5772
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+5780
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+5510
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5436
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 6610, 5780, 5780
                    , 5772, 5780, 5772, 5780, 5510, 5436)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+6610, netSellCostBuyPrice = netSellCostBuyPrice+5780
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+5780
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+5772
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+5780
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+5772
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+5780
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+5510
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+5436;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675adfb7cb7fc and sellbillId = 149143 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:44:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:14:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:14: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-12 11:45:06";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:15:06", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:15:06', '75', 'showDetail', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149142');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:45:14";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:15:14", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:15:14', '75', 'showDetail', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149139');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:45:20";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:15:20", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:15:20', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:45:20";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:15:20", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:15:20', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:45:23";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:15:23", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:15:23', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:45:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:15:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:15: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 0675ae1c1cdac5
-- ----------------------------------------------------------------------------------------------------

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-12 15:14:41', '0675ae1c1cdac5', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-12 15:15:31', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149144', '0', '2024-12-12 15:15:32', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:14:41','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35820;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07171', '149144', '5', '16238', '1', '300', '300', '0', '', '1', '2024-12-12 15:15:32', '16238', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35820-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 = 544977;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16238, '2024-12-12', 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-12', 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 = '104', storedetaildate = '2024-12-12 15:15:32' WHERE storedetailid = '16237';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16238', '1', '1', '1', '149144', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '104', '2024-12-12 15:15:32','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '32115',  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 ('31815','300', '0', '1', 'اضافة فاتورة مبيعات', '149144', '32115', '2024-12-12 15:15:32', '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-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 300, 240, 240
                    , 240, 240, 240, 240, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, 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 0675ae1c1cdac5 and sellbillId = 149144 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:45:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:15:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:15: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-12 11:45:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:15:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:15: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 0675ae1f50d460
-- ----------------------------------------------------------------------------------------------------

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-12 15:15:33', '0675ae1f50d460', '1', '0.00', '0', '0', '1', '420.00', '420', '420', '0', '1', '2024-12-12 15:15:57', '', '104', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','420','0','','0','0','420','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149145', '0', '2024-12-12 15:15:57', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '420', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:15:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35760;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07121', '149145', '5', '16127', '1', '420', '420', '0', '', '1', '2024-12-12 15:15:57', '16127', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35760-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 = 544978;
 INSERT INTO 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-12', 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-12', 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 = '20', userid = '104', storedetaildate = '2024-12-12 15:15:57' WHERE storedetailid = '16126';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16127', '1', '1', '1', '149145', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '104', '2024-12-12 15:15:57','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '32535',  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 ('32115','420', '0', '1', 'اضافة فاتورة مبيعات', '149145', '32535', '2024-12-12 15:15:57', '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-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 420, 360, 360
                    , 358, 360, 358, 356.67, 360, 356)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+420, netSellCostBuyPrice = netSellCostBuyPrice+360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+360
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+358
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+360
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+358
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+356.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+360
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+356;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ae1f50d460 and sellbillId = 149145 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:45:58";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:15:58", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:15: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-12 11:46:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:16:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:16: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 0675ae20e668c1
-- ----------------------------------------------------------------------------------------------------

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-12 15:15:58', '0675ae20e668c1', '1', '0.00', '0', '0', '1', '230.00', '230', '230', '0', '1', '2024-12-12 15:16:25', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','230','0','','0','0','230','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149146', '0', '2024-12-12 15:16:25', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '230', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:15:58','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('180','R3211', '149146', '1', '15456', '1', '230', '230', '0', '', '1', '2024-12-12 15:16:25', '15456', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','230','230','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 = 544979;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15456, '2024-12-12', 230, 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+230, 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-12', 230, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, 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 = '2', userid = '104', storedetaildate = '2024-12-12 15:16:25' WHERE storedetailid = '15455';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15456', '1', '1', '1', '149146', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '104', '2024-12-12 15:16:25','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '32765',  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 ('32535','230', '0', '1', 'اضافة فاتورة مبيعات', '149146', '32765', '2024-12-12 15:16:25', '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-12', 230, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, 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;
 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-12', 230, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 230, 180, 180
                    , 180, 180, 180, 180, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+230, netSellCostBuyPrice = netSellCostBuyPrice+180
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+180
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+180
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+180
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+180
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+180
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ae20e668c1 and sellbillId = 149146 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:46:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:16:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:16: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-12 11:47:16";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:17:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:17: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 0675ae229ec575
-- ----------------------------------------------------------------------------------------------------

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-12 15:16:25', '0675ae229ec575', '1', '0.00', '0', '0', '1', '530.00', '530', '530', '0', '1', '2024-12-12 15:17:16', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','530','0','','0','0','530','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149147', '0', '2024-12-12 15:17:16', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '530', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:16:25','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35100;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','65885', '149147', '5', '15890', '1', '530', '530', '0', '', '1', '2024-12-12 15:17:16', '15890', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35100-1,','1','1','0','0','530','530','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 = 544980;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15890, '2024-12-12', 530, 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+530, 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-12', 530, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, 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 = '104', storedetaildate = '2024-12-12 15:17:16' WHERE storedetailid = '15889';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15890', '1', '1', '1', '149147', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-12 15:17:16','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '33295',  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 ('32765','530', '0', '1', 'اضافة فاتورة مبيعات', '149147', '33295', '2024-12-12 15:17:16', '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-12', 530, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+495
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 530, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+495
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 530, 495, 495
                    , 495, 495, 495, 495, 495, 495)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+530, netSellCostBuyPrice = netSellCostBuyPrice+495
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+495
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+495
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+495
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+495
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+495
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+495
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+495;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ae229ec575 and sellbillId = 149147 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:47:16";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:17:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:17: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-12 11:49:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:19:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:19: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-12 11:49:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:19:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:19: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-12', '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 = '33285',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('33295.00','10', '1', '1', 'إضافة مصروف', '25615', '33285', '2024-12-12 15:19:24', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'فرق فاتورة', expensesdetails = '', expensesValue = '10.00', expensesdate = '2024-12-12', 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 = '25615';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:49:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:19:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:19: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-12 11:49:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:19:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:19: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-12 11:52:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:22:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 15:22:49', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:52:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:22:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 15:22:51', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:53:24";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:23:24", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 15:23: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-12 11:53:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:23:25", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 15:23:25', '104', 'add', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245815
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8939,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '30' , clientdate = '2024-12-12 15:23:25', userid = '104' WHERE clientid = '8939';
UPDATE client SET  inUse = 0 where clientid = 8939;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8939','980.00','950','1','ايصال تحصيل (( قبض من عميل ))','245815', '30', '2024-12-12 15:22:51', '104', 'clientPayedDeptController.php', '   ', '950', '0', null, '0', null, null,'', '-1','1','1','950','1','','3140','0');
UPDATE save SET  savecurrentvalue = '34235',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('33285.00','950', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '245815', '34235', '2024-12-12 15:23:25', '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 ('برباره عطيه d544', 'برباره عطيه d544', 'برباره عطيه d544', 'برباره عطيه d544', '58', '0', '30.00', '0', '', '0', '0', '', '0', '3', '1', '', '104', '0', '2024-12-12 15:23:25');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '950', '950', '2024-12-12', '104', '0', '0', '2024-12-12 15:23:25','اضافة ايصال سداد للعميل برباره عطيه d544','1','0','-1','0','245815','clientPayedDeptController.php?do=show&id=245815');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121722', '-1', '950', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '950', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121722', '12419', '950', '','0');
UPDATE accountstree SET name = 'برباره عطيه d544', customName = 'برباره عطيه d544', customNameEn = 'برباره عطيه d544', nameEn = 'برباره عطيه d544', parent = '58', accountNature = '0', theValue = '-920', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '104', del = '0', sysdate = '2024-12-12 15:23:25' WHERE id = '12419';
UPDATE clientdebtchange SET clientid = '8939', clientdebtchangebefore = '980.000', clientdebtchangeamount = '950.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245815', clientdebtchangeafter = '30.000', clientdebtchangedate = '2024-12-12 15:22:51', userid = '104', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '950.00',discount='', reciptid='0', dailyentryid = '121722',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='950',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245815';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:53:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:23:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 15:23:26', '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-12 11:53:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:23:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 15:23:28', '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-12 11:53:34";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:23:34", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 15:23:34', '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-12 11:53:37";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:23:37", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:23:37', '75', 'showDetail', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=147999');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:55:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:25:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:25: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-12 11:55:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:25:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:25: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 0675ae42d506ce
-- ----------------------------------------------------------------------------------------------------

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-12 15:25:01', '0675ae42d506ce', '1', '0.00', '0', '0', '1', '580.00', '580', '580', '0', '1', '2024-12-12 15:25:55', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149148', '0', '2024-12-12 15:25:55', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '580', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:25:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35732;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('480','H1596', '149148', '14', '16219', '1', '580', '580', '0', '', '1', '2024-12-12 15:25:55', '16219', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35732-1,','1','1','0','0','580','580','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 480.00 , meanbuyprice = 480.00, lastbuyprice_withDiscount = 480.00, meanbuyprice_withDiscount = 480.00
        , lastbuyprice_withTax = 480, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 480
                where sellbilldetailid = 544981;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16219, '2024-12-12', 580, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 580, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '10', userid = '104', storedetaildate = '2024-12-12 15:25:55' WHERE storedetailid = '16218';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16219', '1', '1', '1', '149148', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '104', '2024-12-12 15:25:55','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '34815',  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 ('34235','580', '0', '1', 'اضافة فاتورة مبيعات', '149148', '34815', '2024-12-12 15:25:55', '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-12', 580, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 580, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 580, 480, 480
                    , 480, 480, 480, 480, 480, 480)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+580, netSellCostBuyPrice = netSellCostBuyPrice+480
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+480
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+480
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+480
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+480
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+480
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+480
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+480;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ae42d506ce and sellbillId = 149148 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:55:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:25:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15: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-12 11:59:03";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:29:03", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:29: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 0675ae1e8dae49
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(71,@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-12 15:15:20', '0675ae1e8dae49', '71', '30417.00', '38957', '420', '1', '8960.00', '8540', '0', '8540', '1', '2024-12-12 15:29:03', '', '75', '0', 'الخضراوي', '2', '1', '3', '85', 'الخضراوي', '23' ,'0','','','','','-1','0','0','0','0','0','8540','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '38957', userid = '75' WHERE clientid = '71';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('71','30417.00','8540','0','اضافة فاتورة مبيعات','149149', '38957', '2024-12-12 15:29:03', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '8540', '0', null, '0', null, null,'', '0','1','1','8540','1','2024-12-12 15:15:20','0','0');
UPDATE client SET  inUse = 0 where clientid = 71;
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', '149149', '5', '16350', '1', '620', '620', '0', '', '1', '2024-12-12 15:29:03', '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 = 544982;
 INSERT INTO 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-12', 590.9375, 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+590.9375, 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-12', 590.9375, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0, 575, 575, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+590.9375, 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 = '8', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '16349';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16350', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 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', '149149', '14', '16000', '1', '670', '670', '0', '', '1', '2024-12-12 15:29:04', '16000', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35333-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 = 544983;
 INSERT INTO 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-12', 638.59375, 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+638.59375, 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-12', 638.59375, 585, 585
                    , 585, 585, 585, 585
                    , 0, 0, 0, 0
                    , 0, 0, 0, 585, 585, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+638.59375, 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 = '7', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '15999';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16000', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35858;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149149', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-12 15:29:04', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35858-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 = 544984;
 INSERT INTO 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-12', 457.5, 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+457.5, 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-12', 457.5, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+457.5, 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 = '108', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '109', '108', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35806;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149149', '5', '16234', '1', '550', '550', '0', '', '1', '2024-12-12 15:29:04', '16234', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35806-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 = 544985;
 INSERT INTO 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-12', 524.21875, 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+524.21875, 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-12', 524.21875, 455, 455
                    , 455, 455, 455, 455
                    , 0, 0, 0, 0
                    , 0, 0, 0, 455, 455, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+524.21875, 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 = '37', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '16233';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16234', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '38', '37', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34820;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('360','R3275', '149149', '1', '15818', '1', '420', '420', '0', '', '1', '2024-12-12 15:29:04', '15818', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34820-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 544986;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15818, '2024-12-12', 400.3125, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400.3125, 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-12', 400.3125, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400.3125, 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-12 15:29:04' WHERE storedetailid = '15817';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15818', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35957;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149149', '5', '16275', '1', '330', '330', '0', '', '1', '2024-12-12 15:29:04', '16275', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35957-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 = 282, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 544987;
 INSERT INTO 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-12', 314.53125, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 280, 282, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+314.53125, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+281
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+281
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+282
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 314.53125, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 282, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+314.53125, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+281
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+281
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+282
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 15:29:04' WHERE storedetailid = '16274';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16275', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '42', '41', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35546;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('595','H1576', '149149', '14', '16137', '1', '680', '680', '0', '', '1', '2024-12-12 15:29:04', '16137', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35546-1,','1','1','0','0','680','680','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 595.00 , meanbuyprice = 595.00, lastbuyprice_withDiscount = 595.00, meanbuyprice_withDiscount = 595.00
        , lastbuyprice_withTax = 595, meanbuyprice_withTax = 595, lastbuyprice_withDiscountAndTax = 595
                where sellbilldetailid = 544988;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16137, '2024-12-12', 648.125, 595, 595
                    , 595, 595, 595, 595
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 595, 595, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+648.125, sellCostBuyPrice =sellCostBuyPrice+595
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+595, sellCostMeanBuyPrice = sellCostMeanBuyPrice+595
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+595, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+595
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+595
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+595
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+595
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 648.125, 595, 595
                    , 595, 595, 595, 595
                    , 0, 0, 0, 0
                    , 0, 0, 0, 595, 595, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+648.125, sellCostBuyPrice =sellCostBuyPrice+595
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+595, sellCostMeanBuyPrice = sellCostMeanBuyPrice+595
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+595, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+595
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+595
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+595
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+595
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '3', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '16136';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16137', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35935;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('480','07193', '149149', '5', '16309', '1', '550', '550', '0', '', '1', '2024-12-12 15:29:04', '16309', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35935-1,','1','1','0','0','550','550','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 480.00 , meanbuyprice = 480.00, lastbuyprice_withDiscount = 480.00, meanbuyprice_withDiscount = 480.00
        , lastbuyprice_withTax = 480, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 480
                where sellbilldetailid = 544989;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16309, '2024-12-12', 524.21875, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+524.21875, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+480
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 524.21875, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 480, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+524.21875, 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 = '6', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '16308';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16309', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35928;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('280','07198', '149149', '5', '16304', '1', '320', '320', '0', '', '1', '2024-12-12 15:29:04', '16304', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35928-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        , lastbuyprice_withTax = 280, meanbuyprice_withTax = 280, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 544990;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16304, '2024-12-12', 305, 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+305, 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-12', 305, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+305, 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 = '12', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '16303';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16304', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35804;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07153', '149149', '5', '16213', '1', '210', '210', '0', '', '1', '2024-12-12 15:29:04', '16213', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35804-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 = 544991;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16213, '2024-12-12', 200.15625, 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.15625, 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-12', 200.15625, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200.15625, 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 = '17', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '16212';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16213', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32130;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('195','81776', '149149', '1', '14463', '1', '210', '210', '0', '', '1', '2024-12-12 15:29:04', '14463', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32130-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 195.00, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 195.00
        
                where sellbilldetailid = 544992;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14463, '2024-12-12', 200.15625, 195, 195
                    , 195, 195, 195, 195
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200.15625, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+195
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 200.15625, 195, 195
                    , 195, 195, 195, 195
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200.15625, sellCostBuyPrice =sellCostBuyPrice+195
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+195, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+195, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+195
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '14462';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14463', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35889;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07217', '149149', '5', '16287', '1', '250', '250', '0', '', '1', '2024-12-12 15:29:04', '16287', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35889-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 190, lastbuyprice_withDiscountAndTax = 190
                where sellbilldetailid = 544993;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16287, '2024-12-12', 238.28125, 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+238.28125, 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-12', 238.28125, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+238.28125, 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 = '12', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '16286';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16287', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35899;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149149', '5', '16293', '1', '200', '200', '0', '', '1', '2024-12-12 15:29:04', '16293', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35899-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 = 544994;
 INSERT INTO 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-12', 190.625, 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+190.625, 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-12', 190.625, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190.625, 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 = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37', '36', '75', '2024-12-12 15:29:04','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', '149149', '1', '16274', '1', '460', '460', '0', '', '1', '2024-12-12 15:29:04', '16274', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35870-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 = 544995;
 INSERT INTO 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-12', 438.4375, 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+438.4375, 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-12', 438.4375, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+438.4375, 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 = '15', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '16273';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16274', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35812;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','R3320', '149149', '1', '16236', '1', '200', '200', '0', '', '1', '2024-12-12 15:29:04', '16236', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35812-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 73, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 544996;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16236, '2024-12-12', 190.625, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 145, 73, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190.625, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+73
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 190.625, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 73, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+190.625, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+73
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '13', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '16235';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16236', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35567;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149149', '5', '15673', '1', '360', '360', '0', '', '1', '2024-12-12 15:29:04', '15673', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35567-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 = 544997;
 INSERT INTO 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-12', 343.125, 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+343.125, 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-12', 343.125, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+343.125, 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 = '18', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '15672';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15673', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '75', '2024-12-12 15:29:04','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', '149149', '5', '16297', '1', '580', '580', '0', '', '1', '2024-12-12 15:29:04', '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 = 544998;
 INSERT INTO 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-12', 552.8125, 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+552.8125, 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-12', 552.8125, 510, 510
                    , 510, 510, 510, 510
                    , 0, 0, 0, 0
                    , 0, 0, 0, 510, 510, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+552.8125, 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 = '73', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '74', '73', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35907;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149149', '14', '16167', '1', '410', '410', '0', '', '1', '2024-12-12 15:29:04', '16167', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35907-1,','1','1','0','0','410','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 348.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 348.00
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 347, lastbuyprice_withDiscountAndTax = 350
                where sellbilldetailid = 544999;
 INSERT INTO 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-12', 390.78125, 350, 350
                    , 348, 350, 348, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 350, 347, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390.78125, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+348
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+348
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+347
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 390.78125, 350, 350
                    , 348, 350, 348, 345
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 347, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390.78125, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+348
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+348
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+345
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+347
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 15:29:04' WHERE storedetailid = '16166';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16167', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35878;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149149', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-12 15:29:04', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35878-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 = 545000;
 INSERT INTO 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-12', 772.03125, 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+772.03125, 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-12', 772.03125, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0, 730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+772.03125, 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 = '75', userid = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '76', '75', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36082;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149149', '14', '16163', '1', '280', '280', '0', '', '1', '2024-12-12 15:29:04', '16163', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36082-1,','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 = 545001;
 INSERT INTO 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-12', 266.875, 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+266.875, 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-12', 266.875, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+266.875, 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 = '75', storedetaildate = '2024-12-12 15:29:04' WHERE storedetailid = '16162';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16163', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '75', '2024-12-12 15:29:04','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31801;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06140', '149149', '5', '13898', '1', '260', '260', '0', '', '1', '2024-12-12 15:29:05', '13898', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31801-1,','1','1','0','0','260','260','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 326.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 326.00
        
                where sellbilldetailid = 545002;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13898, '2024-12-12', 247.8125, 330, 330
                    , 326, 330, 326, 325
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+247.8125, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+326
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+326
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+325
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 247.8125, 330, 330
                    , 326, 330, 326, 325
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+247.8125, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+326
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+326
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+325
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 15:29:05' WHERE storedetailid = '13897';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13898', '1', '1', '1', '149149', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 15:29:05','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149149', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 15:29:05', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149149', '17', '10291', '1', '90', '90', '0', '', '1', '2024-12-12 15:29:05', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','90','90','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 85 where clientid = 71;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 8540, 7695, 7695
                    , 7690, 7695, 7690, 7685
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,7170, 7097, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8540, sellCostBuyPrice =sellCostBuyPrice+7695
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7695, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7690
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7695, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7690
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+7685
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+7170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+7097
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (71, '2024-12-12', 8540, 7695, 7695
                    , 7690, 7695, 7690, 7685
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,7170, 7097, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8540, sellCostBuyPrice =sellCostBuyPrice+7695
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7695, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7690
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7695, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7690
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+7685
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+7170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+7097
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 8540, 7695, 7695
                    , 7690, 7695, 7690, 7685, 7170, 7097)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+8540, netSellCostBuyPrice = netSellCostBuyPrice+7695
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+7695
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+7690
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+7695
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+7690
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+7685
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+7170
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+7097;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ae1e8dae49 and sellbillId = 149149 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:59:05";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:29:05", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:29:05', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 11:59:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:29:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:29:30', '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-12 12:01:52";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:31:52", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:31:52', '75', 'showDetail', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149149');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:02:51";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:32:51", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:32: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-12 12:04:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:34:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 15:34:05', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:04:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:34:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 15:34:13', '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-12 12:04:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:34:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:34:38', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:05:59";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 15:35:59", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 15:35:59', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:06:02";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 15:36:02", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:36:02', '2', 'showDetail', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=148220');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:06:05";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 15:36:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 15:36:05', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:07:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:37:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:37:49', '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', 'مرتجع', '', '85', '2024-12-12', '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 = '34730',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('34815.00','85', '1', '1', 'إضافة مصروف', '25616', '34730', '2024-12-12 15:37:49', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'مرتجع', expensesdetails = '', expensesValue = '85.00', expensesdate = '2024-12-12', 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 = '25616';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:07:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:37:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:37:50', '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-12 12:07:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:37:52", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:37:52', '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-12 12:07:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:37:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:37: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-12 12:08:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:38:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:38: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 0675ae734b1a25
-- ----------------------------------------------------------------------------------------------------

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-12 15:37:56', '0675ae734b1a25', '1', '0.00', '0', '0', '1', '420.00', '420', '420', '0', '1', '2024-12-12 15:38:11', '', '104', '0', 'نقدي', '1', '0', '3', '97', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','420','0','','0','0','420','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149150', '0', '2024-12-12 15:38:11', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '420', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:37:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35445;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','16006', '149150', '5', '16006', '1', '420', '420', '0', '', '1', '2024-12-12 15:38:11', '16006', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35445-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 = 545005;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16006, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '104', storedetaildate = '2024-12-12 15:38:11' WHERE storedetailid = '16005';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16006', '1', '1', '1', '149150', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-12 15:38:11','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '35150',  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 ('34730','420', '0', '1', 'اضافة فاتورة مبيعات', '149150', '35150', '2024-12-12 15:38:11', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 97 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 420, 360, 360
                    , 360, 360, 360, 360, 360, 360)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+420, netSellCostBuyPrice = netSellCostBuyPrice+360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+360
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+360
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+360
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+360
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+360
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+360
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+360;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ae734b1a25 and sellbillId = 149150 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:08:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:38:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:38: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-12 12:08:12";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:38:12", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:38: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 0675ae60367637
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6831,@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-12 15:32:51', '0675ae60367637', '6831', '0.00', '394', '0', '1', '394.00', '394', '0', '394', '1', '2024-12-12 15:38:12', '', '75', '0', 'امل برهوم X51', '2', '1', '3', '85', 'امل برهوم X51', '3' ,'0','','','','','-1','0','0','0','0','0','394','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '394', userid = '75' WHERE clientid = '6831';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6831','0.00','394','0','اضافة فاتورة مبيعات','149151', '394', '2024-12-12 15:38:12', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '394', '0', null, '0', null, null,'', '0','1','1','394','1','2024-12-12 15:32:51','0','0');
UPDATE client SET  inUse = 0 where clientid = 6831;
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', '149151', '1', '16120', '1', '370', '370', '0', '', '1', '2024-12-12 15:38:12', '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 = 545006;
 INSERT INTO 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-12', 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-12', 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 = '19', userid = '75', storedetaildate = '2024-12-12 15:38:12' WHERE storedetailid = '16119';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16120', '1', '1', '1', '149151', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '75', '2024-12-12 15:38: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', '149151', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 15:38: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', '149151', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-12 15:38: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 = 85 where clientid = 6831;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 394, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+394, 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 (6831, '2024-12-12', 394, 300, 300
                    , 300, 300, 300, 300
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,300, 300, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+394, 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, 394, 300, 300
                    , 300, 300, 300, 300, 300, 300)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+394, 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 0675ae60367637 and sellbillId = 149151 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:08:13";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:38:13", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:38: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-12 12:08:17";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:38:17", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:38:17', '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-12 12:10:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:40:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:40: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 0675ae744b0126
-- ----------------------------------------------------------------------------------------------------

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-12 15:38:12', '0675ae744b0126', '1', '0.00', '0', '0', '1', '210.00', '210', '210', '0', '1', '2024-12-12 15:40:21', '', '104', '0', 'نقدي', '1', '0', '3', '74', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149152', '0', '2024-12-12 15:40:21', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '210', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:38:12','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 22300;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','0K393', '149152', '7', '9386', '1', '210', '210', '0', '', '1', '2024-12-12 15:40:21', '9386', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','22300-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 272.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 272.00
        
                where sellbilldetailid = 545009;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9386, '2024-12-12', 210, 250, 250
                    , 272, 250, 272, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+272
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+272
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 210, 250, 250
                    , 272, 250, 272, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+272
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+272
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-11', userid = '104', storedetaildate = '2024-12-12 15:40:21' WHERE storedetailid = '9385';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9386', '1', '1', '1', '149152', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-10', '-11', '104', '2024-12-12 15:40:21','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '35360',  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 ('35150','210', '0', '1', 'اضافة فاتورة مبيعات', '149152', '35360', '2024-12-12 15:40:21', '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-12', 210, 250, 250
                    , 272, 250, 272, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+272
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+272
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 210, 250, 250
                    , 272, 250, 272, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+272
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+272
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 210, 250, 250
                    , 272, 250, 272, 250, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+210, netSellCostBuyPrice = netSellCostBuyPrice+250
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+250
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+272
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+250
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+272
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+250
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ae744b0126 and sellbillId = 149152 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:10:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:40:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:40: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-12 12:12:03";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 15:42:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 15:42:03', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:15:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:45:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 15:45: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-12 12:15:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:45:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 15:45:21', '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-12', '104', '0', '0','','1','1','0','0','10000');
UPDATE save SET  savecurrentvalue = '25360',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('35360.00','10000', '1', '1', 'تحويل امول الى الخزنة  [ شيكات وكمبيالات ] ', '3487', '25360', '2024-12-12 15:45:21', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '660000',  userid = '104' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('650000.00','10000', '0', '8', 'تحويل امول من الخزنة  [ نقدي ] ', '3487', '660000', '2024-12-12 15:45:21', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '8', transfermoneyvalue = '10000.00', transfermoneydate = '2024-12-12', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='10000' WHERE transfermoneyid = '3487';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:15:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:45:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 15:45:22', '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-12 12:15:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:45:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 15:45:23', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:15:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:45:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 15:45:30', '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-12', '104', '0', '0','','1','1','0','0','5000');
UPDATE save SET  savecurrentvalue = '20360',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('25360.00','5000', '1', '1', 'تحويل امول الى الخزنة  [ جمعيه ] ', '3488', '20360', '2024-12-12 15:45:30', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '90000',  userid = '104' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('85000.00','5000', '0', '5', 'تحويل امول من الخزنة  [ نقدي ] ', '3488', '90000', '2024-12-12 15:45:30', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '5', transfermoneyvalue = '5000.00', transfermoneydate = '2024-12-12', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='5000' WHERE transfermoneyid = '3488';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:15:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:45:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 15:45:30', '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-12 12:15:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:45:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 15:45:32', '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-12 12:15:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:45:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 15:45:33', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:16:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:46:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 15:46:09', '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-12 12:19:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:49:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:49: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-12 12:19:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:49:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:49: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-12 12:20:05";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 15:50:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:50:05', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:20:13";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 15:50:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:50:13', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:20:14";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:50:14", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:50: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 0675ae749cd2e2
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1312,@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-12 15:38:17', '0675ae749cd2e2', '1312', '23.00', '3346', '0', '1', '3323.00', '3323', '0', '3323', '1', '2024-12-12 15:50:15', '', '75', '0', 'محمود السعيد s109', '2', '1', '3', '91', 'محمود السعيد s109', '9' ,'0','','','','','-1','0','0','0','0','0','3323','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '3346', userid = '75' WHERE clientid = '1312';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1312','23.00','3323','0','اضافة فاتورة مبيعات','149153', '3346', '2024-12-12 15:50:15', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3323', '0', null, '0', null, null,'', '0','1','1','3323','1','2024-12-12 15:38:17','0','0');
UPDATE client SET  inUse = 0 where clientid = 1312;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36027;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('435','H1621', '149153', '14', '16255', '2', '600', '1200', '0', '', '1', '2024-12-12 15:50:15', '16255', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36027-2,','1','1','0','0','600','1200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 435.00 , meanbuyprice = 414.00, lastbuyprice_withDiscount = 435.00, meanbuyprice_withDiscount = 414.00
        , lastbuyprice_withTax = 435, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 435
                where sellbilldetailid = 545010;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16255, '2024-12-12', 1200, 870, 870
                    , 828, 870, 828, 880
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 870, 960, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+870, sellCostMeanBuyPrice = sellCostMeanBuyPrice+828
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+828
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+880
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+960
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+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-12', 1200, 870, 870
                    , 828, 870, 828, 880
                    , 0, 0, 0, 0
                    , 0, 0, 0, 870, 960, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+870, sellCostMeanBuyPrice = sellCostMeanBuyPrice+828
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+828
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+880
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+960
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '21', userid = '75', storedetaildate = '2024-12-12 15:50:15' WHERE storedetailid = '16254';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16255', '1', '2', '1', '149153', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '21', '75', '2024-12-12 15:50:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35845;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1617', '149153', '14', '16253', '1', '410', '410', '0', '', '1', '2024-12-12 15:50:15', '16253', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35845-1,','1','1','0','0','410','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 304.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 304.00
        , lastbuyprice_withTax = 300, meanbuyprice_withTax = 302, lastbuyprice_withDiscountAndTax = 300
                where sellbilldetailid = 545011;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16253, '2024-12-12', 410, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+302
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 410, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+302
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 15:50:15' WHERE storedetailid = '16252';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16253', '1', '1', '1', '149153', 'اضافة فاتورة مبيعات', 'sellbillController.php', '41', '40', '75', '2024-12-12 15:50:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34784;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06795', '149153', '5', '15434', '1', '240', '240', '0', '', '1', '2024-12-12 15:50:15', '15434', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34784-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
        , lastbuyprice_withTax = 180, meanbuyprice_withTax = 108, lastbuyprice_withDiscountAndTax = 180
                where sellbilldetailid = 545012;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15434, '2024-12-12', 240, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 180, 108, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+108
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 240, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 108, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+108
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 15:50:15' WHERE storedetailid = '15433';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15434', '1', '1', '1', '149153', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-12 15:50:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35863;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('255','07186', '149153', '5', '16269', '1', '480', '480', '0', '', '1', '2024-12-12 15:50:15', '16269', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35863-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 255.00 , meanbuyprice = 255.00, lastbuyprice_withDiscount = 255.00, meanbuyprice_withDiscount = 255.00
        , lastbuyprice_withTax = 255, meanbuyprice_withTax = 255, lastbuyprice_withDiscountAndTax = 255
                where sellbilldetailid = 545013;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16269, '2024-12-12', 480, 255, 255
                    , 255, 255, 255, 255
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 255, 255, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+255, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+255
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+255
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+255
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 480, 255, 255
                    , 255, 255, 255, 255
                    , 0, 0, 0, 0
                    , 0, 0, 0, 255, 255, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+255, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+255
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+255
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+255
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 15:50:15' WHERE storedetailid = '16268';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16269', '1', '1', '1', '149153', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-12 15:50:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 16056;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R1688', '149153', '1', '7705', '1', '130', '130', '0', '', '1', '2024-12-12 15:50:15', '7705', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','16056-1,','1','1','0','0','130','130','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 = 545014;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7705, '2024-12-12', 130, 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+130, 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-12', 130, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, 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 = '2', userid = '75', storedetaildate = '2024-12-12 15:50:15' WHERE storedetailid = '7704';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('7705', '1', '1', '1', '149153', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 15:50:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35878;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149153', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-12 15:50:15', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35878-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 = 545015;
 INSERT INTO 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-12', 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-12', 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 = '74', userid = '75', storedetaildate = '2024-12-12 15:50:15' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '149153', 'اضافة فاتورة مبيعات', 'sellbillController.php', '75', '74', '75', '2024-12-12 15:50:15','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149153', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 15:50:15', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149153', '17', '10291', '1', '33', '33', '0', '', '1', '2024-12-12 15:50:15', '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 = 91 where clientid = 1312;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 3323, 2515, 2515
                    , 2477, 2515, 2477, 2526.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2335, 2355, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3323, sellCostBuyPrice =sellCostBuyPrice+2515
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2515, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2477
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2515, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2477
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2526.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2355
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1312, '2024-12-12', 3323, 2515, 2515
                    , 2477, 2515, 2477, 2526.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2335, 2355, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3323, sellCostBuyPrice =sellCostBuyPrice+2515
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2515, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2477
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2515, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2477
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2526.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2355
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3323, 2515, 2515
                    , 2477, 2515, 2477, 2526.5, 2335, 2355)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3323, netSellCostBuyPrice = netSellCostBuyPrice+2515
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2515
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2477
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2515
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2477
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2526.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2335
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2355;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ae749cd2e2 and sellbillId = 149153 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:20:16";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 15:50:16", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:50:16', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:20:35";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 15:50:35", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:50:35', '2', 'editsellBill', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=149046');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:20:45";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 15:50:45", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:50:45', '2', 'update', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

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


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

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 149046;
UPDATE sellbill SET  sellbillsysdate = '2024-12-12 15:50:45', userid = '75',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '149046';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-7 where id = 35875;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-8 where id = 35969;
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 = 544651;
 INSERT INTO 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-12', 9300, 8250, 8250
                    , 8235, 8250, 8205, 8200.05
                    , 0, 0, 0, 0
                    , 0, 0, 0,15,0, 8250, 8220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-9300, sellCostBuyPrice =sellCostBuyPrice-8250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-8250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-8250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8205
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-8200.05
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-8250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-8220
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-15
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 9300, 8250, 8250
                    , 8235, 8250, 8205, 8200.05
                    , 0, 0, 0, 0
                    , 0, 0, 0, 8250, 8220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-9300, sellCostBuyPrice =sellCostBuyPrice-8250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-8250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-8250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8205
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-8200.05
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-8250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-8220
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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 = '2', storedetaildate = '2024-12-12 15:50:45' WHERE storedetailid = '16276';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16277', '1', '15', '0', '149046', 'تعديل فاتورة مبيعات', 'sellbillController.php', '79', '94', '2', '2024-12-11 18:32:28','0','0');
CALL clientInUse(1098,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-4086', userid = '2' WHERE clientid = '1098';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1098','5308.00','9394.00','1','تعديل فاتورة مبيعات','149046', '-4086', '2024-12-11 18:32:28', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '9394', '0', null, '0', null, null,'', '0','1','1','9394','1','2024-12-11 18:32:28','0','0');
UPDATE client SET  inUse = 0 where clientid = 1098;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 9394, 8250, 8250
                    , 8235, 8250, 8205, 8200.05
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,8250, 8220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-9394, sellCostBuyPrice =sellCostBuyPrice-8250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-8250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-8250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8205
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-8200.05
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-8250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-8220
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1098, '2024-12-12', 9394, 8250, 8250
                    , 8235, 8250, 8205, 8200.05
                    , 0, 0, 0, 0
                    , 0, 0, 0, 8250, 8220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-9394, sellCostBuyPrice =sellCostBuyPrice-8250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-8250, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-8250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8205
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-8200.05
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-8250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-8220
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 9394, 8250, 8250
                    , 8235, 8250, 8205, 8200.05, 8250, 8220)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-9394, netSellCostBuyPrice = netSellCostBuyPrice-8250
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-8250
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-8235
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-8250
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-8205
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-8200.05
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-8250
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-8220;

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


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

COMMIT;
BEGIN;
CALL clientInUse(1098,@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-11 18:32:28', '06759be9c5c478', '1098', '-4086.00', '5008', '0', '1', '9094', '9094', '0', '9094', '1', '2024-12-11 18:32:28', '', '2', '0', 'اميرة الهرم t148', '2', '1', '3', '89', 'اميرة الهرم t148', '16', '149046', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-11','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '5008', userid = '2' WHERE clientid = '1098';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1098','-4086.00','9094','0','اضافة فاتورة مبيعات (معدله)','149154', '5008', '2024-12-12 15:50:45', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '9094', '0', null, '0', null, null,'', '0','1','1','9394','1','2024-12-11 18:32:28','0','0');
UPDATE client SET  inUse = 0 where clientid = 1098;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+7 where id = 35875;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+8 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', '149154', '1', '16277', '15', '600', '9000', '0', '', '1', '2024-12-12 15:50:45', '16277', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35875-7,35969-8,','1','1','0','0','600','9000','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 = 545018;
 INSERT INTO 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-12', 9000, 8250, 8250
                    , 8235, 8250, 8205, 8200.05
                    , 0, 0, 0, 0
                    , 0, 0, 0, 15, 0, 8250, 8220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9000, sellCostBuyPrice =sellCostBuyPrice+8250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8205
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+8200.05
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+8250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+8220
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+15
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 9000, 8250, 8250
                    , 8235, 8250, 8205, 8200.05
                    , 0, 0, 0, 0
                    , 0, 0, 0, 8250, 8220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9000, sellCostBuyPrice =sellCostBuyPrice+8250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8205
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+8200.05
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+8250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+8220
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '79', userid = '2', storedetaildate = '2024-12-12 15:50:45' WHERE storedetailid = '16276';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16277', '1', '15', '1', '149154', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '94', '79', '2', '2024-12-12 15:50: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 ('0','10291', '149154', '17', '10291', '1', '94', '94', '0', '', '1', '2024-12-12 15:50:45', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','94','94','0','','0','0.00','0','0','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 9094, 8250, 8250
                    , 8235, 8250, 8205, 8200.05
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,8250, 8220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9094, sellCostBuyPrice =sellCostBuyPrice+8250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8205
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+8200.05
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+8250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+8220
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1098, '2024-12-12', 9094, 8250, 8250
                    , 8235, 8250, 8205, 8200.05
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,8250, 8220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9094, sellCostBuyPrice =sellCostBuyPrice+8250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8205
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+8200.05
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+8250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+8220
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 9094, 8250, 8250
                    , 8235, 8250, 8205, 8200.05, 8250, 8220)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+9094, netSellCostBuyPrice = netSellCostBuyPrice+8250
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+8250
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+8235
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+8250
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+8205
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+8200.05
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+8250
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+8220;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 149046 and newid=149154 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:20:46";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 15:50:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:50:46', '2', 'editprint', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=149154');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:20:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:50:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:50:49', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ae9f9ce11a
-- ----------------------------------------------------------------------------------------------------

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-12 15:49:45', '0675ae9f9ce11a', '1', '0.00', '0', '0', '1', '810.00', '810', '810', '0', '1', '2024-12-12 15:50:49', '', '104', '0', 'نقدي', '1', '0', '3', '96', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149155', '0', '2024-12-12 15:50:49', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '810', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:49:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36051;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('735','07231', '149155', '5', '16342', '1', '810', '810', '0', '', '1', '2024-12-12 15:50:49', '16342', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36051-1,','1','1','0','0','810','810','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 735.00 , meanbuyprice = 732.00, lastbuyprice_withDiscount = 735.00, meanbuyprice_withDiscount = 732.00
        , lastbuyprice_withTax = 735, meanbuyprice_withTax = 728, lastbuyprice_withDiscountAndTax = 735
                where sellbilldetailid = 545020;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16342, '2024-12-12', 810, 735, 735
                    , 732, 735, 732, 735
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 735, 728, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+732
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+732
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+735
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+728
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 810, 735, 735
                    , 732, 735, 732, 735
                    , 0, 0, 0, 0
                    , 0, 0, 0, 735, 728, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+732
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+732
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+735
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+728
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 15:50:49' WHERE storedetailid = '16341';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16342', '1', '1', '1', '149155', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '104', '2024-12-12 15:50:49','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '21170',  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 ('20360','810', '0', '1', 'اضافة فاتورة مبيعات', '149155', '21170', '2024-12-12 15:50:49', '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-12', 810, 735, 735
                    , 732, 735, 732, 735
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,735, 728, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+732
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+732
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+735
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+728
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 810, 735, 735
                    , 732, 735, 732, 735
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,735, 728, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+732
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+732
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+735
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+728
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 735, 735
                    , 732, 735, 732, 735, 735, 728)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+810, netSellCostBuyPrice = netSellCostBuyPrice+735
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+735
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+732
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+735
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+732
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+735
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+735
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+728;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ae9f9ce11a and sellbillId = 149155 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:20:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:50:50", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:50: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-12 12:23:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:53:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:53:38', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:23:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:53:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:53:45', '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-12', '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 = '21120',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('21170.00','50', '1', '1', 'إضافة مصروف', '25617', '21120', '2024-12-12 15:53:45', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'لاحا', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25617';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:23:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:53:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:53:45', '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-12 12:23:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:53:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 15:53:47', '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-12 12:26:12";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 15:56:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:56:12', '2', 'showDetail', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149046');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:27:18";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 15:57:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 15:57:18', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245804
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245804 -clientdebtchangeId = 245825
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245826
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245827
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245828
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245829
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245830
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:29:06";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 15:59:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 15:59:06', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:29:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 15:59:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 15:59:29', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675aec23932dd
-- ----------------------------------------------------------------------------------------------------

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-12 15:58:59', '0675aec23932dd', '1', '0.00', '0', '0', '1', '310.00', '310', '310', '0', '1', '2024-12-12 15:59:29', '', '104', '0', 'نقدي', '1', '0', '3', '26', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149156', '0', '2024-12-12 15:59:29', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '310', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:58:59','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', '149156', '5', '16321', '1', '310', '310', '0', '', '1', '2024-12-12 15:59:29', '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 = 545021;
 INSERT INTO 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-12', 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-12', 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 = '31', userid = '104', storedetaildate = '2024-12-12 15:59:29' WHERE storedetailid = '16320';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16321', '1', '1', '1', '149156', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32', '31', '104', '2024-12-12 15:59:29','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '21430',  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 ('21120','310', '0', '1', 'اضافة فاتورة مبيعات', '149156', '21430', '2024-12-12 15:59:29', '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-12', 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-12', 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 0675aec23932dd and sellbillId = 149156 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245831
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245831 -clientdebtchangeId = 245832
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:30:23";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:00:23", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:00:23', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:30:50";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:00:50", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:00:50', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245833
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9439,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '4' , clientdate = '2024-12-12 16:00:51', userid = '2' WHERE clientid = '9439';
UPDATE client SET  inUse = 0 where clientid = 9439;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9439','899.00','895','1','ايصال تحصيل (( قبض من عميل ))','245833', '4', '2024-12-12 16:00:23', '2', 'clientPayedDeptController.php', '   ', '895', '0', null, '0', null, null,'', '-1','1','1','895','1','','3147','0');
UPDATE save SET  savecurrentvalue = '468996.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('468101.50','895', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245833', '468996.5', '2024-12-12 16:00:51', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '895', '895', '2024-12-12', '2', '0', '0', '2024-12-12 16:00:51','اضافة ايصال سداد للعميل فاطمة محمود المنيا k458','1','0','0','0','245833','clientPayedDeptController.php?do=show&id=245833');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121730', '-1', '895', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '895', 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 ('121730', '-1', '895', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-895', 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 = '9439', clientdebtchangebefore = '899.000', clientdebtchangeamount = '895.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245833', clientdebtchangeafter = '4.000', clientdebtchangedate = '2024-12-12 16:00:23', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '895.00',discount='', reciptid='0', dailyentryid = '121730',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='895',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245833';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:30:51";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:00:51", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:00:52', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:32:12";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:02:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:02:12', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245834
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(3053,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-313' , clientdate = '2024-12-12 16:02:12', userid = '2' WHERE clientid = '3053';
UPDATE client SET  inUse = 0 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','0.00','313','1','ايصال تحصيل (( قبض من عميل ))','245834', '-313', '2024-12-12 16:00:52', '2', 'clientPayedDeptController.php', '   ', '313', '0', null, '0', null, null,'', '-1','1','1','313','1','','3148','0');
UPDATE save SET  savecurrentvalue = '469309.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('468996.50','313', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245834', '469309.5', '2024-12-12 16:02:12', '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 ('نجوي محمد B717', 'نجوي محمد B717', 'نجوي محمد B717', 'نجوي محمد B717', '58', '0', '-313.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-12 16:02:12');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '313', '313', '2024-12-12', '2', '0', '0', '2024-12-12 16:02:12','اضافة ايصال سداد للعميل نجوي محمد B717','1','0','0','0','245834','clientPayedDeptController.php?do=show&id=245834');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121731', '-1', '313', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '313', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121731', '12422', '313', '','0');
UPDATE accountstree SET name = 'نجوي محمد B717', customName = 'نجوي محمد B717', customNameEn = 'نجوي محمد B717', nameEn = 'نجوي محمد B717', parent = '58', accountNature = '0', theValue = '-626', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-12 16:02:12' WHERE id = '12422';
UPDATE clientdebtchange SET clientid = '3053', clientdebtchangebefore = '0.000', clientdebtchangeamount = '313.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245834', clientdebtchangeafter = '-313.000', clientdebtchangedate = '2024-12-12 16:00:52', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '313.00',discount='', reciptid='0', dailyentryid = '121731',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='313',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245834';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:32:13";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:02:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:02:13', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:33:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:03:26", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:03: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 0675aec428f6e1
-- ----------------------------------------------------------------------------------------------------

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-12 15:59:30', '0675aec428f6e1', '1', '0.00', '0', '0', '1', '100.00', '100', '100', '0', '1', '2024-12-12 16:03:26', '', '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-12','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','اضافة فاتورة مبيعات','149157', '0', '2024-12-12 16:03:26', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '100', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:59:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29656;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2708', '149157', '1', '13279', '1', '100', '100', '0', '', '1', '2024-12-12 16:03:26', '13279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29656-1,','1','1','0','0','100','100','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 2420.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 2420.00
        
                where sellbilldetailid = 545022;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13279, '2024-12-12', 100, 220, 220
                    , 2420, 220, 2420, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2420
                            , 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-12', 100, 220, 220
                    , 2420, 220, 2420, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2420
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '104', storedetaildate = '2024-12-12 16:03:26' WHERE storedetailid = '13278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13279', '1', '1', '1', '149157', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-12 16:03:26','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '21530',  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 ('21430','100', '0', '1', 'اضافة فاتورة مبيعات', '149157', '21530', '2024-12-12 16:03:26', '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-12', 100, 220, 220
                    , 2420, 220, 2420, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2420
                            , 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;
 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-12', 100, 220, 220
                    , 2420, 220, 2420, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2420
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 100, 220, 220
                    , 2420, 220, 2420, 220, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+100, netSellCostBuyPrice = netSellCostBuyPrice+220
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+220
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2420
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+220
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2420
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+220
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aec428f6e1 and sellbillId = 149157 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675aea1867469
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5689,@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-12 15:50:16', '0675aea1867469', '5689', '0.00', '424', '0', '1', '424.00', '424', '0', '424', '1', '2024-12-12 16:06:29', '', '75', '0', 'يارا صيام F101', '2', '1', '3', '87', 'يارا صيام F101', '3' ,'0','','','','','-1','0','0','0','0','0','424','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '424', userid = '75' WHERE clientid = '5689';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5689','0.00','424','0','اضافة فاتورة مبيعات','149158', '424', '2024-12-12 16:06:29', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '424', '0', null, '0', null, null,'', '0','1','1','424','1','2024-12-12 15:50:16','0','0');
UPDATE client SET  inUse = 0 where clientid = 5689;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35880;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149158', '5', '16279', '1', '400', '400', '0', '', '1', '2024-12-12 16:06:29', '16279', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35880-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 = 545023;
 INSERT INTO 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-12', 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-12', 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 = '54', userid = '75', storedetaildate = '2024-12-12 16:06:29' WHERE storedetailid = '16278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16279', '1', '1', '1', '149158', 'اضافة فاتورة مبيعات', 'sellbillController.php', '55', '54', '75', '2024-12-12 16:06: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', '149158', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 16:06: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', '149158', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-12 16:06:29', '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 = 5689;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 424, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+424, 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 (5689, '2024-12-12', 424, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 285, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+424, 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, 424, 335, 335
                    , 335, 335, 335, 335, 335, 285)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+424, 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 0675aea1867469 and sellbillId = 149158 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675aededf03ad
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4193,@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-12 16:06:37', '0675aededf03ad', '4193', '0.00', '-255', '0', '1', '255', '255', '0', '-255', '1', '2024-12-12 16:10:39', '', '101', '0', 'مريم عسيلي F3','2', '1', '5', '86', 'مريم عسيلي F3', '1', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '-255', userid = '101' WHERE clientid = '4193';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4193','0.00','255','1','اضافة فاتورة مردوات مبيعات','16738', '-255', '2024-12-12 16:10:39', '101', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '255', '0', null, '0', null, null,'', '0','1','1','255','1','2024-12-12 16:06:37','0','0');
UPDATE client SET  inUse = 0 where clientid = 4193;
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 ('195.00', '07084', '16738', '5', '16078', '1', '255', '255', '0', '', '1', '0', '16078', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','255','255','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 195.00, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 195.00
        , lastbuyprice_withTax = 195, meanbuyprice_withTax = 195, lastbuyprice_withDiscountAndTax = 195
                where returnsellbilldetailid = 21898;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16078, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 255, 195, 195, 195
                    , 195, 195, 195, 0, 1, 0, 0, 195, 195)
                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+195, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+195
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+195
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+195
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+195
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+195
                        , 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 255, 195, 195, 195
                    , 195, 195, 195, 0, 0, 195, 195)
                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+195, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+195
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+195
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+195
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+195
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+195;
UPDATE storedetail SET  productquantity = '7', userid = '101', storedetaildate = '2024-12-12 16:10:39' WHERE storedetailid = '16077';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16078', '1', '1', '0', '16738', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '6', '7', '101', '2024-12-12 16:10:39','0','0');
UPDATE client SET  delegateid = 86 where clientid = 4193;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 255, 195, 195, 195
                    , 195, 195, 195 ,0, 0, 195, 195)
                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+195, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+195
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+195
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+195
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+195
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+195;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4193, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 255, 195, 195, 195
                    , 195, 195, 195 ,0, 0, 195, 195)
                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+195, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+195
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+195, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+195
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+195
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+195
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+195
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+195;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -255, -195, -195
                    , -195, -195, -195, -195, -195, -195)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-255, netSellCostBuyPrice = netSellCostBuyPrice+-195
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-195
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-195
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-195
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-195
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-195
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-195
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-195;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aededf03ad and sellbillId = 16738 and returnsellbillId = 16738
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:40:40";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:10:40", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:10:40', '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-12 12:41:17";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:11:17", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 16:11:17', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:41:29";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:11:29", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 16:11:29', '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-12 12:41:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:11:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:11: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 0675aed2f18e0c
-- ----------------------------------------------------------------------------------------------------

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-12 16:03:27', '0675aed2f18e0c', '1', '0.00', '0', '0', '1', '130.00', '130', '130', '0', '1', '2024-12-12 16:11:32', '', '104', '0', 'نقدي', '1', '0', '3', '8', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','130','0','','0','0','130','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149159', '0', '2024-12-12 16:11:32', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '130', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 16:03:27','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33011;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3041', '149159', '1', '14755', '1', '130', '130', '0', '', '1', '2024-12-12 16:11:32', '14755', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33011-1,','1','1','0','0','130','130','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
        
                where sellbilldetailid = 545026;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14755, '2024-12-12', 130, 115, 115
                    , 115, 115, 115, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+115
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 130, 115, 115
                    , 115, 115, 115, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+115
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 16:11:32' WHERE storedetailid = '14754';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14755', '1', '1', '1', '149159', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '104', '2024-12-12 16:11:32','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '21660',  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 ('21530','130', '0', '1', 'اضافة فاتورة مبيعات', '149159', '21660', '2024-12-12 16:11: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-12', 130, 115, 115
                    , 115, 115, 115, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+115
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 130, 115, 115
                    , 115, 115, 115, 115
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, sellCostBuyPrice =sellCostBuyPrice+115
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+115, sellCostMeanBuyPrice = sellCostMeanBuyPrice+115
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+115, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+115
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+115
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 130, 115, 115
                    , 115, 115, 115, 115, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+130, netSellCostBuyPrice = netSellCostBuyPrice+115
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+115
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+115
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+115
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+115
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+115
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aed2f18e0c and sellbillId = 149159 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:41:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:11:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:11: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-12 12:41:33";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:11:33", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:11:33', '101', 'showDetail', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=146937');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:44:26";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:14:26", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:14: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 0675aeee054f42
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8372,@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-12 16:10:40', '0675aeee054f42', '8372', '1.00', '-309', '0', '1', '310', '310', '0', '-310', '1', '2024-12-12 16:14:26', '', '101', '0', 'مدام انجي خيري P377','2', '1', '5', '82', 'مدام انجي خيري P377', '1', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '-309', userid = '101' WHERE clientid = '8372';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8372','1.00','310','1','اضافة فاتورة مردوات مبيعات','16739', '-309', '2024-12-12 16:14:26', '101', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '310', '0', null, '0', null, null,'', '0','1','1','310','1','2024-12-12 16:10:40','0','0');
UPDATE client SET  inUse = 0 where clientid = 8372;
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 ('210.00', 'H1529', '16739', '14', '16030', '1', '310', '310', '0', '', '1', '0', '16030', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','310','310','0','','0');
UPDATE returnsellbilldetail 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 returnsellbilldetailid = 21899;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16030, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 310, 210, 210, 210
                    , 210, 210, 210, 0, 1, 0, 0, 210, 210)
                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+210, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+210, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+210
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+210
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+210
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+210
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+210
                        , 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 310, 210, 210, 210
                    , 210, 210, 210, 0, 0, 210, 210)
                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+210, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+210, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+210
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+210
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+210
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+210
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+210;
UPDATE storedetail SET  productquantity = '-8', userid = '101', storedetaildate = '2024-12-12 16:14:26' WHERE storedetailid = '16029';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16030', '1', '1', '0', '16739', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '-9', '-8', '101', '2024-12-12 16:14:26','0','0');
UPDATE client SET  delegateid = 82 where clientid = 8372;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 310, 210, 210, 210
                    , 210, 210, 210 ,0, 0, 210, 210)
                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+210, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+210, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+210
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+210
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+210
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+210
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+210;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8372, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 310, 210, 210, 210
                    , 210, 210, 210 ,0, 0, 210, 210)
                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+210, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+210
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+210, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+210
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+210
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+210
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+210
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+210;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -310, -210, -210
                    , -210, -210, -210, -210, -210, -210)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-310, netSellCostBuyPrice = netSellCostBuyPrice+-210
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-210
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-210
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-210
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-210
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-210
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-210
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-210;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aeee054f42 and sellbillId = 16739 and returnsellbillId = 16739
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:44:27";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:14:27", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:14: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-12 12:46:46";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:16:46", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 16:16:46', '101', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:47:18";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 16:17:18", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:17: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 0675aede6601c4
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1058,@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-12 16:06:30', '0675aede6601c4', '1058', '0.00', '737', '0', '1', '737.00', '737', '0', '737', '1', '2024-12-12 16:17:18', '', '75', '0', 'سارة احمد محمود73', '2', '1', '3', '83', 'سارة احمد محمود73', '5' ,'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-12','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 = '1058';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1058','0.00','737','0','اضافة فاتورة مبيعات','149160', '737', '2024-12-12 16:17:18', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '737', '0', null, '0', null, null,'', '0','1','1','737','1','2024-12-12 16:06:30','0','0');
UPDATE client SET  inUse = 0 where clientid = 1058;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35649;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('260','R3304', '149160', '1', '16045', '1', '310', '310', '0', '', '1', '2024-12-12 16:17:18', '16045', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35649-1,','1','1','0','0','310','310','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 260.00
        , lastbuyprice_withTax = 260, meanbuyprice_withTax = 260, lastbuyprice_withDiscountAndTax = 260
                where sellbilldetailid = 545027;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16045, '2024-12-12', 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-12', 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 = '11', userid = '75', storedetaildate = '2024-12-12 16:17:18' WHERE storedetailid = '16044';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16045', '1', '1', '1', '149160', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-12 16:17:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '149160', '5', '16300', '2', '200', '400', '0', '', '1', '2024-12-12 16:17:18', '16300', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35923-2,','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 545028;
 INSERT INTO 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-12', 400, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 400, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '75', storedetaildate = '2024-12-12 16:17:18' WHERE storedetailid = '16299';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16300', '1', '2', '1', '149160', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '11', '75', '2024-12-12 16:17: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', '149160', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 16:17: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', '149160', '17', '10291', '1', '7', '7', '0', '', '1', '2024-12-12 16:17:19', '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 = 83 where clientid = 1058;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 737, 540, 540
                    , 540, 540, 540, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,540, 540, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+737, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1058, '2024-12-12', 737, 540, 540
                    , 540, 540, 540, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,540, 540, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+737, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 737, 540, 540
                    , 540, 540, 540, 540, 540, 540)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+737, netSellCostBuyPrice = netSellCostBuyPrice+540
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+540
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+540
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+540
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+540
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+540
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+540
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+540;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675aede6601c4 and sellbillId = 149160 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:47:19";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 16:17:19", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:17: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-12 12:48:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:18:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:18: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 0675ae4647a2bb
-- ----------------------------------------------------------------------------------------------------

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-12 15:25:56', '0675ae4647a2bb', '1', '0.00', '0', '0', '1', '610.00', '610', '610', '0', '1', '2024-12-12 16:18:15', '', '104', '0', 'نقدي', '1', '0', '3', '3', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','610','0','','0','0','610','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149161', '0', '2024-12-12 16:18:15', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '610', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 15:25:56','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', '149161', '14', '15622', '1', '610', '610', '0', '', '1', '2024-12-12 16:18:15', '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 = 545031;
 INSERT INTO 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-12', 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-12', 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 = '24', userid = '104', storedetaildate = '2024-12-12 16:18:15' WHERE storedetailid = '15621';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15622', '1', '1', '1', '149161', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '104', '2024-12-12 16:18:15','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22270',  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 ('21660','610', '0', '1', 'اضافة فاتورة مبيعات', '149161', '22270', '2024-12-12 16:18: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-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 610, 500, 500
                    , 501, 500, 501, 425.29, 500, 509)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+610, 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 0675ae4647a2bb and sellbillId = 149161 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675af06fc0c08
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2722,@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-12 16:17:19', '0675af06fc0c08', '2722', '0.00', '1152', '0', '1', '1152.00', '1152', '0', '1152', '1', '2024-12-12 16:18:24', '', '75', '0', 'ريم الباهي w341', '2', '1', '3', '83', 'ريم الباهي w341', '4' ,'0','','','','','-1','0','0','0','0','0','1152','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1152', userid = '75' WHERE clientid = '2722';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2722','0.00','1152','0','اضافة فاتورة مبيعات','149162', '1152', '2024-12-12 16:18:24', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1152', '0', null, '0', null, null,'', '0','1','1','1152','1','2024-12-12 16:17:19','0','0');
UPDATE client SET  inUse = 0 where clientid = 2722;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36027;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('435','H1621', '149162', '14', '16255', '1', '600', '600', '0', '', '1', '2024-12-12 16:18:24', '16255', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36027-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 435.00 , meanbuyprice = 414.00, lastbuyprice_withDiscount = 435.00, meanbuyprice_withDiscount = 414.00
        , lastbuyprice_withTax = 435, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 435
                where sellbilldetailid = 545032;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16255, '2024-12-12', 600, 435, 435
                    , 414, 435, 414, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 435, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+435
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+435, sellCostMeanBuyPrice = sellCostMeanBuyPrice+414
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+435, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+414
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 600, 435, 435
                    , 414, 435, 414, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 435, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, sellCostBuyPrice =sellCostBuyPrice+435
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+435, sellCostMeanBuyPrice = sellCostMeanBuyPrice+414
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+435, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+414
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '20', userid = '75', storedetaildate = '2024-12-12 16:18:24' WHERE storedetailid = '16254';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16255', '1', '1', '1', '149162', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '75', '2024-12-12 16:18:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36266;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1634', '149162', '14', '16361', '1', '520', '520', '0', '', '1', '2024-12-12 16:18:24', '16361', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36266-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 = 545033;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16361, '2024-12-12', 520, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 520, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '75', storedetaildate = '2024-12-12 16:18:24' WHERE storedetailid = '16360';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16361', '1', '1', '1', '149162', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-12 16:18: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', '149162', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 16:18: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', '149162', '17', '10291', '1', '12', '12', '0', '', '1', '2024-12-12 16:18:24', '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 = 83 where clientid = 2722;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1152, 845, 845
                    , 824, 845, 824, 850
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,845, 890, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1152, sellCostBuyPrice =sellCostBuyPrice+845
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+845, sellCostMeanBuyPrice = sellCostMeanBuyPrice+824
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+845, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+824
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+850
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+845
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+890
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2722, '2024-12-12', 1152, 845, 845
                    , 824, 845, 824, 850
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,845, 890, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1152, sellCostBuyPrice =sellCostBuyPrice+845
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+845, sellCostMeanBuyPrice = sellCostMeanBuyPrice+824
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+845, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+824
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+850
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+845
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+890
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1152, 845, 845
                    , 824, 845, 824, 850, 845, 890)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1152, netSellCostBuyPrice = netSellCostBuyPrice+845
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+845
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+824
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+845
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+824
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+850
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+845
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+890;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af06fc0c08 and sellbillId = 149162 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675aefc33871c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7148,@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-12 16:14:27', '0675aefc33871c', '7148', '0.00', '-430', '0', '1', '430', '430', '0', '-430', '1', '2024-12-12 16:21:41', '', '101', '0', 'هبة رجب Z25','2', '1', '5', '98', 'هبة رجب Z25', '1', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '-430', userid = '101' WHERE clientid = '7148';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7148','0.00','430','1','اضافة فاتورة مردوات مبيعات','16740', '-430', '2024-12-12 16:21:41', '101', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '430', '0', null, '0', null, null,'', '0','1','1','430','1','2024-12-12 16:14:27','0','0');
UPDATE client SET  inUse = 0 where clientid = 7148;
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('350.00', '07008', '16740', '5', '15992', '1', '430', '430', '0', '', '1', '0', '15992', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','430','430','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 350, lastbuyprice_withDiscountAndTax = 350
                where returnsellbilldetailid = 21900;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15992, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 430, 350, 350, 350
                    , 350, 350, 350, 0, 1, 0, 0, 350, 350)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+430, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+350
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+350
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+350
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 430, 350, 350, 350
                    , 350, 350, 350, 0, 0, 350, 350)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+430, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+350
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+350
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+350;
UPDATE storedetail SET  productquantity = '4', userid = '101', storedetaildate = '2024-12-12 16:21:41' WHERE storedetailid = '15991';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15992', '1', '1', '0', '16740', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '3', '4', '101', '2024-12-12 16:21:41','0','0');
UPDATE client SET  delegateid = 98 where clientid = 7148;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 430, 350, 350, 350
                    , 350, 350, 350 ,0, 0, 350, 350)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+430, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+350
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+350
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+350;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7148, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 430, 350, 350, 350
                    , 350, 350, 350 ,0, 0, 350, 350)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+430, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+350
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+350
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+350;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -430, -350, -350
                    , -350, -350, -350, -350, -350, -350)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-430, 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 0675aefc33871c and sellbillId = 16740 and returnsellbillId = 16740
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:51:42";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:21:42", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:21:42', '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-12 12:51:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:21:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:21:59', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675af0a82becf
-- ----------------------------------------------------------------------------------------------------

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-12 16:18:16', '0675af0a82becf', '1', '0.00', '0', '0', '1', '420.00', '420', '420', '0', '1', '2024-12-12 16:21:59', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','420','0','','0','0','420','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149163', '0', '2024-12-12 16:21:59', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '420', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 16:18:16','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35448;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','16040', '149163', '5', '16040', '1', '420', '420', '0', '', '1', '2024-12-12 16:21:59', '16040', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35448-1,','1','1','0','0','420','420','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 353.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 353.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 345, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 545036;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16040, '2024-12-12', 420, 360, 360
                    , 353, 360, 353, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 345, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+353
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+353
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , 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
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 420, 360, 360
                    , 353, 360, 353, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 345, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+353
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+353
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , 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;
UPDATE storedetail SET  productquantity = '7', userid = '104', storedetaildate = '2024-12-12 16:21:59' WHERE storedetailid = '16039';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16040', '1', '1', '1', '149163', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '104', '2024-12-12 16:21:59','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22690',  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 ('22270','420', '0', '1', 'اضافة فاتورة مبيعات', '149163', '22690', '2024-12-12 16:21:59', '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-12', 420, 360, 360
                    , 353, 360, 353, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,360, 345, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+353
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+353
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , 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 (1, '2024-12-12', 420, 360, 360
                    , 353, 360, 353, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,360, 345, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+353
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+353
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , 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, 420, 360, 360
                    , 353, 360, 353, 360, 360, 345)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+420, netSellCostBuyPrice = netSellCostBuyPrice+360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+360
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+353
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+360
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+353
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+360
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+360
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+345;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af0a82becf and sellbillId = 149163 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:52:00";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:22:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:22:00', '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-12 12:54:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:24:13", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:24:13', '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-12 12:54:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:24:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:24: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 0675af20d864e0
-- ----------------------------------------------------------------------------------------------------

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-12 16:24:13', '0675af20d864e0', '1', '0.00', '0', '0', '1', '470', '470', '-470', '0', '1', '2024-12-12 16:24:30', '', '104', '0', 'نقدي','1', '0', '5', '5', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-470','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '104' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16741', '0', '2024-12-12 16:24:30', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '470', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 16:24:13','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('390.00', 'H1423', '16741', '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 = 21901;
 INSERT INTO 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-12', 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-12', 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 = '70', userid = '104', storedetaildate = '2024-12-12 16:24:30' WHERE storedetailid = '15708';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15709', '1', '1', '0', '16741', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '69', '70', '104', '2024-12-12 16:24:30','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22220',  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 ('22690','-470', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16741', '22220', '2024-12-12 16:24:30', '104',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 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-12', 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 0675af20d864e0 and sellbillId = 16741 and returnsellbillId = 16741
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:54:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:24:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:24:31', '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-12 12:54:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:24:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:24: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-12 12:55:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:25:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:25: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 0675af22eeb2db
-- ----------------------------------------------------------------------------------------------------

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-12 16:24:46', '0675af22eeb2db', '1', '0.00', '0', '0', '1', '620.00', '620', '620', '0', '1', '2024-12-12 16:25:17', '', '104', '0', 'نقدي', '1', '0', '3', '24', 'نقدي', '2' ,'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-12','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','اضافة فاتورة مبيعات','149164', '0', '2024-12-12 16:25:17', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '620', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 16:24:46','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 28558;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','05482', '149164', '5', '11928', '2', '310', '620', '0', '', '1', '2024-12-12 16:25:17', '11928', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','28558-2,','1','1','0','0','310','620','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 270.00 , meanbuyprice = 269.00, lastbuyprice_withDiscount = 270.00, meanbuyprice_withDiscount = 269.00
        
                where sellbilldetailid = 545037;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11928, '2024-12-12', 620, 540, 540
                    , 538, 540, 538, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+538
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+538
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 620, 540, 540
                    , 538, 540, 538, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+538
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+538
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '104', storedetaildate = '2024-12-12 16:25:17' WHERE storedetailid = '11927';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11928', '1', '2', '1', '149164', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '9', '104', '2024-12-12 16:25:17','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22840',  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 ('22220','620', '0', '1', 'اضافة فاتورة مبيعات', '149164', '22840', '2024-12-12 16:25:17', '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-12', 620, 540, 540
                    , 538, 540, 538, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+538
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+538
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 620, 540, 540
                    , 538, 540, 538, 540
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+620, sellCostBuyPrice =sellCostBuyPrice+540
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+540, sellCostMeanBuyPrice = sellCostMeanBuyPrice+538
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+540, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+538
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+540
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 620, 540, 540
                    , 538, 540, 538, 540, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+620, netSellCostBuyPrice = netSellCostBuyPrice+540
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+540
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+538
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+540
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+538
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+540
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af22eeb2db and sellbillId = 149164 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:55:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:25:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:25: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-12 12:57:16";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 16:27:16", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:27: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 0675af0b19f354
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9047,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-12 16:18:25', '0675af0b19f354', '9047', '0.00', '8081', '0', '1', '8081.00', '8081', '0', '8081', '1', '2024-12-12 16:27:17', '', '75', '0', 'مي السويس  B503', '2', '1', '3', '90', 'مي السويس  B503', '29' ,'0','','','','','-1','0','0','0','0','0','8081','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '8081', userid = '75' WHERE clientid = '9047';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9047','0.00','8081','0','اضافة فاتورة مبيعات','149165', '8081', '2024-12-12 16:27:17', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '8081', '0', null, '0', null, null,'', '0','1','1','8081','1','2024-12-12 16:18:25','0','0');
UPDATE client SET  inUse = 0 where clientid = 9047;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+6 where id = 36119;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149165', '5', '16022', '6', '200', '1200', '0', '', '1', '2024-12-12 16:27:17', '16022', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36119-6,','1','1','0','0','200','1200','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 = 545038;
 INSERT INTO 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-12', 1200, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 6, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, 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+6
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 1200, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, 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 = '-4', userid = '75', storedetaildate = '2024-12-12 16:27:17' WHERE storedetailid = '16021';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16022', '1', '6', '1', '149165', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '-4', '75', '2024-12-12 16:27:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+4 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', '149165', '5', '16295', '4', '260', '1040', '0', '', '1', '2024-12-12 16:27:17', '16295', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35903-4,','1','1','0','0','260','1040','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 = 545039;
 INSERT INTO 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-12', 1040, 800, 800
                    , 800, 800, 800, 800
                    , 0, 0, 0, 0
                    , 0, 0, 0, 4, 0, 800, 800, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1040, 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+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-12', 1040, 800, 800
                    , 800, 800, 800, 800
                    , 0, 0, 0, 0
                    , 0, 0, 0, 800, 800, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1040, 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 = '6', userid = '75', storedetaildate = '2024-12-12 16:27:17' WHERE storedetailid = '16294';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16295', '1', '4', '1', '149165', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '6', '75', '2024-12-12 16:27:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36104;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06603', '149165', '5', '15038', '1', '290', '290', '0', '', '1', '2024-12-12 16:27:17', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36104-1,','1','1','0','0','290','290','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 = 234, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 545040;
 INSERT INTO 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-12', 290, 240, 240
                    , 235, 240, 235, 239.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 234, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+234
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 290, 240, 240
                    , 235, 240, 235, 239.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 234, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+234
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 16:27:17' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '1', '1', '149165', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-7', '-8', '75', '2024-12-12 16:27:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35901;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149165', '5', '16294', '2', '210', '420', '0', '', '1', '2024-12-12 16:27:17', '16294', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35901-2,','1','1','0','0','210','420','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 = 545041;
 INSERT INTO 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-12', 420, 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+420, 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-12', 420, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, 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 = '46', userid = '75', storedetaildate = '2024-12-12 16:27:17' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '2', '1', '149165', 'اضافة فاتورة مبيعات', 'sellbillController.php', '48', '46', '75', '2024-12-12 16:27:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35804;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35900;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07153', '149165', '5', '16213', '3', '210', '630', '0', '', '1', '2024-12-12 16:27:17', '16213', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35804-2,35900-1,','1','1','0','0','210','630','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 = 545042;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16213, '2024-12-12', 630, 465, 465
                    , 465, 465, 465, 465
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 465, 465, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+630, sellCostBuyPrice =sellCostBuyPrice+465
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+465, sellCostMeanBuyPrice = sellCostMeanBuyPrice+465
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+465, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+465
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+465
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+465
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+465
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-12', 630, 465, 465
                    , 465, 465, 465, 465
                    , 0, 0, 0, 0
                    , 0, 0, 0, 465, 465, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+630, sellCostBuyPrice =sellCostBuyPrice+465
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+465, sellCostMeanBuyPrice = sellCostMeanBuyPrice+465
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+465, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+465
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+465
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+465
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+465
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 16:27:17' WHERE storedetailid = '16212';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16213', '1', '3', '1', '149165', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '14', '75', '2024-12-12 16:27:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35601;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07122', '149165', '5', '16124', '1', '200', '200', '0', '', '1', '2024-12-12 16:27:17', '16124', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35601-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 = 545043;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16124, '2024-12-12', 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-12', 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 = '4', userid = '75', storedetaildate = '2024-12-12 16:27:17' WHERE storedetailid = '16123';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16124', '1', '1', '1', '149165', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 16:27: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 ('140','07051', '149165', '5', '16247', '1', '200', '200', '0', '', '1', '2024-12-12 16:27:17', '16247', '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 = 170.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 200, meanbuyprice_withTax = 200, lastbuyprice_withDiscountAndTax = 200
                where sellbilldetailid = 545044;
 INSERT INTO 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-12', 200, 140, 200
                    , 170, 200, 170, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , 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-12', 200, 140, 200
                    , 170, 200, 170, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+200, sellCostBuyPrice =sellCostBuyPrice+140
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , 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 = '-22', userid = '75', storedetaildate = '2024-12-12 16:27:17' WHERE storedetailid = '16246';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16247', '1', '1', '1', '149165', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-21', '-22', '75', '2024-12-12 16:27:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35604;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07126', '149165', '5', '16155', '2', '200', '400', '0', '', '1', '2024-12-12 16:27:17', '16155', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35604-1,','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 545045;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16155, '2024-12-12', 400, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 400, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '75', storedetaildate = '2024-12-12 16:27:17' WHERE storedetailid = '16154';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16155', '1', '2', '1', '149165', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '0', '75', '2024-12-12 16:27:17','0','0');
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', '149165', '5', '16201', '1', '570', '570', '0', '', '1', '2024-12-12 16:27:17', '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 = 545046;
 INSERT INTO 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-12', 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-12', 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 = '17', userid = '75', storedetaildate = '2024-12-12 16:27:17' WHERE storedetailid = '16200';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16201', '1', '1', '1', '149165', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '75', '2024-12-12 16:27:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36004;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149165', '5', '15970', '1', '200', '200', '0', '', '1', '2024-12-12 16:27:17', '15970', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36004-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 = 128, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 545047;
 INSERT INTO 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-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 200, 140, 140
                    , 140, 140, 140, 140.62
                    , 0, 0, 0, 0
                    , 0, 0, 0, 140, 128, 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.62
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+140
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+128
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 16:27:17' WHERE storedetailid = '15969';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15970', '1', '1', '1', '149165', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-6', '-7', '75', '2024-12-12 16:27:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 35878;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149165', '5', '16205', '3', '810', '2430', '0', '', '1', '2024-12-12 16:27:17', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35878-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 = 545048;
 INSERT INTO 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-12', 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-12', 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 = '71', userid = '75', storedetaildate = '2024-12-12 16:27:17' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '3', '1', '149165', 'اضافة فاتورة مبيعات', 'sellbillController.php', '74', '71', '75', '2024-12-12 16:27:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '149165', '5', '16301', '2', '200', '400', '0', '', '1', '2024-12-12 16:27:17', '16301', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35924-2,','1','1','0','0','200','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 140.00 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140.00, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where sellbilldetailid = 545049;
 INSERT INTO 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-12', 400, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 400, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+280
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '9', userid = '75', storedetaildate = '2024-12-12 16:27:17' WHERE storedetailid = '16300';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16301', '1', '2', '1', '149165', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '9', '75', '2024-12-12 16:27: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', '149165', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 16:27: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', '149165', '17', '10291', '1', '81', '81', '0', '', '1', '2024-12-12 16:27:17', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','81','81','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 90 where clientid = 9047;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 8081, 6325, 6385
                    , 6347, 6385, 6347, 6383.28
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,6385, 6364, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8081, sellCostBuyPrice =sellCostBuyPrice+6325
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6347
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6347
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6383.28
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+6385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+6364
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9047, '2024-12-12', 8081, 6325, 6385
                    , 6347, 6385, 6347, 6383.28
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,6385, 6364, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8081, sellCostBuyPrice =sellCostBuyPrice+6325
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6347
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6347
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6383.28
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+6385
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+6364
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 8081, 6325, 6385
                    , 6347, 6385, 6347, 6383.28, 6385, 6364)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+8081, netSellCostBuyPrice = netSellCostBuyPrice+6325
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+6385
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+6347
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+6385
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+6347
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+6383.28
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+6385
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+6364;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af0b19f354 and sellbillId = 149165 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675af2c688ba2
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7060,@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-12 16:27:18', '0675af2c688ba2', '7060', '21.00', '1112', '0', '1', '1091.00', '1091', '0', '1091', '1', '2024-12-12 16:28:40', '', '75', '0', 'سارة بشر I350', '2', '1', '3', '81', 'سارة بشر I350', '4' ,'0','','','','','-1','0','0','0','0','0','1091','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1112', userid = '75' WHERE clientid = '7060';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7060','21.00','1091','0','اضافة فاتورة مبيعات','149166', '1112', '2024-12-12 16:28:40', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1091', '0', null, '0', null, null,'', '0','1','1','1091','1','2024-12-12 16:27:18','0','0');
UPDATE client SET  inUse = 0 where clientid = 7060;
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', '149166', '5', '16297', '1', '580', '580', '0', '', '1', '2024-12-12 16:28:40', '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 = 545052;
 INSERT INTO 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-12', 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-12', 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 = '72', userid = '75', storedetaildate = '2024-12-12 16:28:40' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '1', '149166', 'اضافة فاتورة مبيعات', 'sellbillController.php', '73', '72', '75', '2024-12-12 16:28:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35858;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149166', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-12 16:28:40', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35858-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 = 545053;
 INSERT INTO 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-12', 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-12', 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 = '107', userid = '75', storedetaildate = '2024-12-12 16:28:40' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '149166', 'اضافة فاتورة مبيعات', 'sellbillController.php', '108', '107', '75', '2024-12-12 16:28: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', '149166', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 16:28:40', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149166', '17', '10291', '1', '11', '11', '0', '', '1', '2024-12-12 16:28:40', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','11','11','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 81 where clientid = 7060;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1091, 930, 930
                    , 930, 930, 930, 930
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,930, 930, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1091, 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 (7060, '2024-12-12', 1091, 930, 930
                    , 930, 930, 930, 930
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,930, 930, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1091, 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, 1091, 930, 930
                    , 930, 930, 930, 930, 930, 930)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1091, 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 0675af2c688ba2 and sellbillId = 149166 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 12:58:41";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 16:28:41", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:28:41', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:02:23";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 16:32:23", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 16:32:23', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:02:34";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 16:32:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 16:32:34', '2', 'add', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =95
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(95,@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 ('95','51.00','51','1','تسوية عجز عميل بالخصم','-1', '0', '2024-12-12 16:32:34', '2', 'clientDeficitController.php', '', '51', '0', null, '0', null, null,'', '0','1','1','51','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12', userid = '2' WHERE clientid = '95';
UPDATE client SET  inUse = 0 where clientid = 95;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =95 ,id=245849
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:02:34";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 16:32:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 16:32:34', '2', 'sucess', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:02:36";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 16:32:36", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 16:32:36', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:05:44";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 16:35:44", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:35: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 0675af3196a609
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10541,@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-12 16:28:41', '0675af3196a609', '10541', '1002.00', '1386', '0', '1', '384.00', '384', '0', '384', '1', '2024-12-12 16:35:45', '', '75', '0', 'افتكسات بنات 100', '2', '1', '3', '83', 'افتكسات بنات 100', '2' ,'0','','','','','-1','0','0','0','0','0','384','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1386', userid = '75' WHERE clientid = '10541';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10541','1002.00','384','0','اضافة فاتورة مبيعات','149167', '1386', '2024-12-12 16:35:45', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '384', '0', null, '0', null, null,'', '0','1','1','384','1','2024-12-12 16:28:41','0','0');
UPDATE client SET  inUse = 0 where clientid = 10541;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 30932;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06153', '149167', '5', '13934', '1', '380', '380', '0', '', '1', '2024-12-12 16:35:45', '13934', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','30932-1,','1','1','0','0','380','380','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 = 545056;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13934, '2024-12-12', 380, 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+380, 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-12', 380, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+495
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '75', storedetaildate = '2024-12-12 16:35:45' WHERE storedetailid = '13933';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13934', '1', '1', '1', '149167', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 16:35: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 ('0','10291', '149167', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-12 16:35:45', '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 = 83 where clientid = 10541;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 384, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+384, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10541, '2024-12-12', 384, 495, 495
                    , 495, 495, 495, 495
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+384, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 384, 495, 495
                    , 495, 495, 495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+384, netSellCostBuyPrice = netSellCostBuyPrice+495
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+495
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+495
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+495
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+495
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+495
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af3196a609 and sellbillId = 149167 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:05:45";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 16:35:45", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:35: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-12 13:09:08";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:39:08", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 16:39:08', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:09:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:39:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 16:39:21', '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-12', '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 = '22830',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('22840.00','10', '1', '1', 'إضافة مصروف', '25618', '22830', '2024-12-12 16:39:21', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'ابراهيم ', expensesdetails = '', expensesValue = '10.00', expensesdate = '2024-12-12', 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 = '25618';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:09:21";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:39:21", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 16:39:21', '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-12 13:09:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:39:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 16:39:23', '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-12 13:09:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:39:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:39:30', '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-12 13:10:39";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 16:40:39", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:40:39', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675af4c1e8373
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10337,@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-12 16:35:45', '0675af4c1e8373', '10337', '0.00', '1657', '0', '1', '1657.00', '1657', '0', '1657', '1', '2024-12-12 16:40:39', '', '75', '0', 'رغدة ابراهيم77', '2', '1', '3', '100', 'رغدة ابراهيم77', '4' ,'0','','','','','-1','0','0','0','0','0','1657','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1657', userid = '75' WHERE clientid = '10337';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10337','0.00','1657','0','اضافة فاتورة مبيعات','149168', '1657', '2024-12-12 16:40:39', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1657', '0', null, '0', null, null,'', '0','1','1','1657','1','2024-12-12 16:35:45','0','0');
UPDATE client SET  inUse = 0 where clientid = 10337;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('830','H1391', '149168', '14', '15598', '1', '970', '970', '0', '', '1', '2024-12-12 16:40:40', '15598', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','970','970','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 830.00 , meanbuyprice = 1092.00, lastbuyprice_withDiscount = 830.00, meanbuyprice_withDiscount = 1092.00
        , lastbuyprice_withTax = 830, meanbuyprice_withTax = 877
                where sellbilldetailid = 545058;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15598, '2024-12-12', 970, 830, 830
                    , 1092, 830, 1092, 615
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 830, 877, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+970, sellCostBuyPrice =sellCostBuyPrice+830
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+830, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1092
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+830, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1092
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+615
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+830
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+877
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 970, 830, 830
                    , 1092, 830, 1092, 615
                    , 0, 0, 0, 0
                    , 0, 0, 0, 830, 877, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+970, sellCostBuyPrice =sellCostBuyPrice+830
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+830, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1092
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+830, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1092
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+615
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+830
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+877
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 16:40:40' WHERE storedetailid = '15597';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15598', '1', '1', '1', '149168', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-22', '-23', '75', '2024-12-12 16:40:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35969;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('550','R3327', '149168', '1', '16277', '1', '650', '650', '0', '', '1', '2024-12-12 16:40:40', '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 = 545059;
 INSERT INTO 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-12', 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-12', 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 = '78', userid = '75', storedetaildate = '2024-12-12 16:40:40' WHERE storedetailid = '16276';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16277', '1', '1', '1', '149168', 'اضافة فاتورة مبيعات', 'sellbillController.php', '79', '78', '75', '2024-12-12 16:40: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', '149168', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 16:40:40', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149168', '17', '10291', '1', '17', '17', '0', '', '1', '2024-12-12 16:40:40', '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 = 100 where clientid = 10337;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1657, 1380, 1380
                    , 1641, 1380, 1639, 1161.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1380, 1425, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1657, sellCostBuyPrice =sellCostBuyPrice+1380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1641
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1639
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1161.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1425
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10337, '2024-12-12', 1657, 1380, 1380
                    , 1641, 1380, 1639, 1161.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1380, 1425, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1657, sellCostBuyPrice =sellCostBuyPrice+1380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1641
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1639
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1161.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1425
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1657, 1380, 1380
                    , 1641, 1380, 1639, 1161.67, 1380, 1425)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1657, netSellCostBuyPrice = netSellCostBuyPrice+1380
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1380
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1641
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1380
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1639
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1161.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1380
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1425;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af4c1e8373 and sellbillId = 149168 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:10:40";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 16:40:40", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:40:40', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
update user set blockedByLimits = 0;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:11:11";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 16:41:12", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 16:41:12', '77', '', '192.168.1.73', '', '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-12 13:11:12";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:11:44";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 16:41:44", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 16:41:44', '77', 'bill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:13:02";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 16:43:02", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-12 16:43:02', '77', '', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:13:42";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 16:43:42", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-12 16:43:42', '77', 'show', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:16:29";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:46:29", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:46:29', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675add8d97a03
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8477,@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-12 14:56:45', '0675add8d97a03', '8477', '0.00', '1737', '0', '1', '1737.00', '1737', '0', '1737', '1', '2024-12-12 16:46:30', '', '101', '0', 'ولاء وجيه P417', '2', '1', '3', '82', 'ولاء وجيه P417', '7' ,'0','','','','','-1','0','0','0','0','0','1737','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1737', userid = '101' WHERE clientid = '8477';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8477','0.00','1737','0','اضافة فاتورة مبيعات','149169', '1737', '2024-12-12 16:46:30', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1737', '0', null, '0', null, null,'', '0','1','1','1737','1','2024-12-12 14:56:45','0','0');
UPDATE client SET  inUse = 0 where clientid = 8477;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '149169', '1', '14377', '2', '290', '580', '0', '', '1', '2024-12-12 16:46:30', '14377', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32344-2,','1','1','0','0','290','580','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 = 545062;
 INSERT INTO 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-12', 580, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-12', 580, 480, 480
                    , 480, 480, 480, 480
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, sellCostBuyPrice =sellCostBuyPrice+480
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+480, sellCostMeanBuyPrice = sellCostMeanBuyPrice+480
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+480, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+480
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 16:46:30' WHERE storedetailid = '14376';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14377', '1', '2', '1', '149169', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '6', '101', '2024-12-12 16:46:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35367;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07045', '149169', '5', '16025', '1', '240', '240', '0', '', '1', '2024-12-12 16:46:30', '16025', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35367-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where sellbilldetailid = 545063;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16025, '2024-12-12', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '101', storedetaildate = '2024-12-12 16:46:30' WHERE storedetailid = '16024';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16025', '1', '1', '1', '149169', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '101', '2024-12-12 16:46:30','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', '149169', '14', '16259', '1', '360', '360', '0', '', '1', '2024-12-12 16:46:30', '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 = 545064;
 INSERT INTO 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-12', 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-12', 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 = '14', userid = '101', storedetaildate = '2024-12-12 16:46:30' WHERE storedetailid = '16258';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16259', '1', '1', '1', '149169', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '101', '2024-12-12 16:46:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36266;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1634', '149169', '14', '16361', '1', '520', '520', '0', '', '1', '2024-12-12 16:46:30', '16361', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36266-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 = 545065;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16361, '2024-12-12', 520, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 520, 410, 410
                    , 410, 410, 410, 410
                    , 0, 0, 0, 0
                    , 0, 0, 0, 410, 410, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+410
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+410
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+410
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '101', storedetaildate = '2024-12-12 16:46:30' WHERE storedetailid = '16360';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16361', '1', '1', '1', '149169', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '101', '2024-12-12 16:46: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', '149169', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 16:46:30', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149169', '17', '10291', '1', '17', '17', '0', '', '1', '2024-12-12 16:46:30', '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 = 82 where clientid = 8477;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1737, 1360, 1360
                    , 1360, 1360, 1360, 1360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,880, 880, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1737, sellCostBuyPrice =sellCostBuyPrice+1360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1360
                            , 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8477, '2024-12-12', 1737, 1360, 1360
                    , 1360, 1360, 1360, 1360
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,880, 880, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1737, sellCostBuyPrice =sellCostBuyPrice+1360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1360
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1737, 1360, 1360
                    , 1360, 1360, 1360, 1360, 880, 880)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1737, netSellCostBuyPrice = netSellCostBuyPrice+1360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1360
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1360
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1360
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1360
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1360
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+880
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+880;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675add8d97a03 and sellbillId = 149169 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675af74732230
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9357,@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-12 16:46:31', '0675af74732230', '9357', '0.00', '263', '0', '1', '263.00', '263', '0', '263', '1', '2024-12-12 16:47:53', '', '101', '0', 'انجي رفعت 61', '2', '1', '3', '88', 'انجي رفعت 61', '3' ,'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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '263', userid = '101' WHERE clientid = '9357';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9357','0.00','263','0','اضافة فاتورة مبيعات','149170', '263', '2024-12-12 16:47:53', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '263', '0', null, '0', null, null,'', '0','1','1','263','1','2024-12-12 16:46:31','0','0');
UPDATE client SET  inUse = 0 where clientid = 9357;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35367;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07045', '149170', '5', '16025', '1', '240', '240', '0', '', '1', '2024-12-12 16:47:53', '16025', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35367-1,','1','1','0','0','240','240','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where sellbilldetailid = 545068;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16025, '2024-12-12', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 240, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+240, sellCostBuyPrice =sellCostBuyPrice+170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+170
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+170
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+170
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '7', userid = '101', storedetaildate = '2024-12-12 16:47:53' WHERE storedetailid = '16024';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16025', '1', '1', '1', '149170', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '101', '2024-12-12 16:47: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', '149170', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 16:47: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', '149170', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-12 16:47:53', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','3','3','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 88 where clientid = 9357;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 263, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+263, 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 (9357, '2024-12-12', 263, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,170, 170, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+263, 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, 263, 170, 170
                    , 170, 170, 170, 170, 170, 170)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+263, 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 0675af74732230 and sellbillId = 149170 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:17:53";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:47:53", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:47:53', '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-12 13:19:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:49:18", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:49: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 0675af5a308bc5
-- ----------------------------------------------------------------------------------------------------

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-12 16:39:31', '0675af5a308bc5', '1', '0.00', '0', '0', '1', '2530.00', '2530', '2530', '0', '1', '2024-12-12 16:49:18', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '6' ,'0','','','','','-1','0','0','0','0','0','2530','0','','0','0','2530','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149171', '0', '2024-12-12 16:49:18', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2530', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 16:39:31','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', '149171', '5', '16297', '1', '580', '580', '0', '', '1', '2024-12-12 16:49:18', '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 = 545071;
 INSERT INTO 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-12', 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-12', 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 = '71', userid = '104', storedetaildate = '2024-12-12 16:49:18' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '1', '149171', 'اضافة فاتورة مبيعات', 'sellbillController.php', '72', '71', '104', '2024-12-12 16:49:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35573;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07106', '149171', '5', '16135', '1', '420', '420', '0', '', '1', '2024-12-12 16:49:18', '16135', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35573-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 = 545072;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16135, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '104', storedetaildate = '2024-12-12 16:49:19' WHERE storedetailid = '16134';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16135', '1', '1', '1', '149171', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '104', '2024-12-12 16:49:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35694;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07111', '149171', '5', '16128', '1', '420', '420', '0', '', '1', '2024-12-12 16:49:19', '16128', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35694-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 = 545073;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16128, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '28', userid = '104', storedetaildate = '2024-12-12 16:49:19' WHERE storedetailid = '16127';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16128', '1', '1', '1', '149171', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29', '28', '104', '2024-12-12 16:49:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35760;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07121', '149171', '5', '16127', '1', '420', '420', '0', '', '1', '2024-12-12 16:49:19', '16127', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35760-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 = 545074;
 INSERT INTO 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-12', 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-12', 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 = '19', userid = '104', storedetaildate = '2024-12-12 16:49:19' WHERE storedetailid = '16126';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16127', '1', '1', '1', '149171', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '104', '2024-12-12 16:49:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35103;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3286', '149171', '1', '15892', '1', '280', '280', '0', '', '1', '2024-12-12 16:49:19', '15892', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35103-1,','1','1','0','0','280','280','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 = 545075;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15892, '2024-12-12', 280, 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+280, 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-12', 280, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+280, 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 = '3', userid = '104', storedetaildate = '2024-12-12 16:49:19' WHERE storedetailid = '15891';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15892', '1', '1', '1', '149171', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-12 16:49:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35540;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07097', '149171', '5', '16130', '1', '410', '410', '0', '', '1', '2024-12-12 16:49:19', '16130', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35540-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 = 545076;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16130, '2024-12-12', 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-12', 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 = '9', userid = '104', storedetaildate = '2024-12-12 16:49:19' WHERE storedetailid = '16129';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16130', '1', '1', '1', '149171', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-12 16:49:19','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '25360',  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 ('22830','2530', '0', '1', 'اضافة فاتورة مبيعات', '149171', '25360', '2024-12-12 16:49: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-12', 2530, 2190, 2190
                    , 2188, 2190, 2188, 2186.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2190, 2186, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2530, sellCostBuyPrice =sellCostBuyPrice+2190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2188
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2188
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2186.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2186
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 2530, 2190, 2190
                    , 2188, 2190, 2188, 2186.67
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2190, 2186, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2530, sellCostBuyPrice =sellCostBuyPrice+2190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2188
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2188
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2186.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2186
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2530, 2190, 2190
                    , 2188, 2190, 2188, 2186.67, 2190, 2186)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2530, netSellCostBuyPrice = netSellCostBuyPrice+2190
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2190
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2188
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2190
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2188
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2186.67
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2190
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2186;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af5a308bc5 and sellbillId = 149171 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675af5e8e918d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9079,@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-12 16:40:40', '0675af5e8e918d', '9079', '0.00', '2677', '0', '1', '2677.00', '2677', '0', '2677', '1', '2024-12-12 16:49:24', '', '75', '0', 'رينا المنصورة W711', '2', '1', '3', '83', 'رينا المنصورة W711', '7' ,'0','','','','','-1','0','0','0','0','0','2677','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2677', userid = '75' WHERE clientid = '9079';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9079','0.00','2677','0','اضافة فاتورة مبيعات','149172', '2677', '2024-12-12 16:49:24', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2677', '0', null, '0', null, null,'', '0','1','1','2677','1','2024-12-12 16:40:40','0','0');
UPDATE client SET  inUse = 0 where clientid = 9079;
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', '149172', '14', '16388', '1', '670', '670', '0', '', '1', '2024-12-12 16:49:24', '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 = 545077;
 INSERT INTO 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-12', 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-12', 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 = '28', userid = '75', storedetaildate = '2024-12-12 16:49:24' WHERE storedetailid = '16387';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16388', '1', '1', '1', '149172', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29', '28', '75', '2024-12-12 16:49: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', '149172', '5', '16355', '1', '300', '300', '0', '', '1', '2024-12-12 16:49: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 = 545078;
 INSERT INTO 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-12', 300, 250, 250
                    , 245, 250, 245, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 300, 250, 250
                    , 245, 250, 245, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+245
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+245
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '22', userid = '75', storedetaildate = '2024-12-12 16:49: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', '149172', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23', '22', '75', '2024-12-12 16:49:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35905;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('400','R3319', '149172', '1', '16223', '1', '470', '470', '0', '', '1', '2024-12-12 16:49:24', '16223', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35905-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 = 545079;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16223, '2024-12-12', 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-12', 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 = '8', userid = '75', storedetaildate = '2024-12-12 16:49:24' WHERE storedetailid = '16222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16223', '1', '1', '1', '149172', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-12 16:49:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 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', '149172', '1', '16186', '1', '380', '380', '0', '', '1', '2024-12-12 16:49:24', '16186', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35938-1,','1','1','0','0','380','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 310.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 310.00
        , lastbuyprice_withTax = 310, meanbuyprice_withTax = 310, lastbuyprice_withDiscountAndTax = 310
                where sellbilldetailid = 545080;
 INSERT INTO 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-12', 380, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 380, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '27', userid = '75', storedetaildate = '2024-12-12 16:49:24' WHERE storedetailid = '16185';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16186', '1', '1', '1', '149172', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28', '27', '75', '2024-12-12 16:49:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35878;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149172', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-12 16:49:24', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35878-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 = 545081;
 INSERT INTO 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-12', 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-12', 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 = '70', userid = '75', storedetaildate = '2024-12-12 16:49:24' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '149172', 'اضافة فاتورة مبيعات', 'sellbillController.php', '71', '70', '75', '2024-12-12 16:49: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', '149172', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 16:49: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', '149172', '17', '10291', '1', '27', '27', '0', '', '1', '2024-12-12 16:49:24', '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 = 9079;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 2677, 2275, 2275
                    , 2270, 2275, 2270, 2275
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2275, 2265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2677, sellCostBuyPrice =sellCostBuyPrice+2275
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2275, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2275, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2275
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2275
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9079, '2024-12-12', 2677, 2275, 2275
                    , 2270, 2275, 2270, 2275
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2275, 2265, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2677, sellCostBuyPrice =sellCostBuyPrice+2275
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2275, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2275, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2275
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2275
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2265
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2677, 2275, 2275
                    , 2270, 2275, 2270, 2275, 2275, 2265)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2677, netSellCostBuyPrice = netSellCostBuyPrice+2275
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2275
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2270
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2275
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2270
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2275
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2275
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2265;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af5e8e918d and sellbillId = 149172 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:19:25";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 16:49:25", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:49: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-12 13:20:04";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:50:04", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:50: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 0675af79a0214e
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9354,@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-12 16:47:54', '0675af79a0214e', '9354', '0.00', '919', '0', '1', '919.00', '919', '0', '919', '1', '2024-12-12 16:50:05', '', '101', '0', 'عبدالفتاح محمد', '2', '1', '3', '88', 'عبدالفتاح محمد', '5' ,'0','','','','','-1','0','0','0','0','0','919','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '919', userid = '101' WHERE clientid = '9354';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9354','0.00','919','0','اضافة فاتورة مبيعات','149173', '919', '2024-12-12 16:50:05', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '919', '0', null, '0', null, null,'', '0','1','1','919','1','2024-12-12 16:47:54','0','0');
UPDATE client SET  inUse = 0 where clientid = 9354;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34500;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06857', '149173', '5', '15630', '1', '230', '230', '0', '', '1', '2024-12-12 16:50:05', '15630', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34500-1,','1','1','0','0','230','230','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 = 545084;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15630, '2024-12-12', 230, 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+230, 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-12', 230, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, 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-12 16:50:05' WHERE storedetailid = '15629';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15630', '1', '1', '1', '149173', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '101', '2024-12-12 16:50:05','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', '149173', '5', '15653', '1', '360', '360', '0', '', '1', '2024-12-12 16:50:05', '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 = 322.00, lastbuyprice_withDiscount = 295.00, meanbuyprice_withDiscount = 322.00
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 322, lastbuyprice_withDiscountAndTax = 295
                where sellbilldetailid = 545085;
 INSERT INTO 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-12', 360, 295, 295
                    , 322, 295, 322, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 295, 322, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+322
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+322
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+322
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 360, 295, 295
                    , 322, 295, 322, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0, 295, 322, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+322
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+322
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+322
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '17', userid = '101', storedetaildate = '2024-12-12 16:50:05' WHERE storedetailid = '15652';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15653', '1', '1', '1', '149173', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '101', '2024-12-12 16:50:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35963;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07216', '149173', '5', '16314', '1', '300', '300', '0', '', '1', '2024-12-12 16:50:05', '16314', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35963-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 = 545086;
 INSERT INTO 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-12', 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-12', 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 = '21', userid = '101', storedetaildate = '2024-12-12 16:50:05' WHERE storedetailid = '16313';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16314', '1', '1', '1', '149173', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '101', '2024-12-12 16:50:05','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149173', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 16:50:05', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149173', '17', '10291', '1', '9', '9', '0', '', '1', '2024-12-12 16:50:05', '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 = 88 where clientid = 9354;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 919, 700, 700
                    , 727, 700, 727, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,700, 727, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+919, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+727
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+727
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+727
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9354, '2024-12-12', 919, 700, 700
                    , 727, 700, 727, 700
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,700, 727, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+919, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+727
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+727
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+700
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+700
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+727
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 919, 700, 700
                    , 727, 700, 727, 700, 700, 727)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+919, netSellCostBuyPrice = netSellCostBuyPrice+700
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+700
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+727
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+700
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+727
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+700
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+700
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+727;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af79a0214e and sellbillId = 149173 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:20:06";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:50:06", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:50:06', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:20:53";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 16:50:53", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:50:53', '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-12 13:20:57";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 16:50:57", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:50:57', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675ae745ac660
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6831,@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-12 15:38:13', '0675ae745ac660', '6831', '394.00', '697', '0', '1', '303.00', '303', '0', '303', '1', '2024-12-12 16:50:58', '', '75', '0', 'امل برهوم X51', '2', '1', '3', '85', 'امل برهوم X51', '2' ,'0','','','','','-1','0','0','0','0','0','303','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '697', userid = '75' WHERE clientid = '6831';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6831','394.00','303','0','اضافة فاتورة مبيعات','149174', '697', '2024-12-12 16:50:58', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '303', '0', null, '0', null, null,'', '0','1','1','303','1','2024-12-12 15:38:13','0','0');
UPDATE client SET  inUse = 0 where clientid = 6831;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35626;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149174', '5', '16170', '1', '300', '300', '0', '', '1', '2024-12-12 16:50:58', '16170', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35626-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 = 545089;
 INSERT INTO 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-12', 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-12', 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 = '17', userid = '75', storedetaildate = '2024-12-12 16:50:58' WHERE storedetailid = '16169';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16170', '1', '1', '1', '149174', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '75', '2024-12-12 16:50:58','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149174', '17', '10291', '1', '3', '3', '0', '', '1', '2024-12-12 16:50:58', '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 = 6831;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 303, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+303, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (6831, '2024-12-12', 303, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+303, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 303, 250, 250
                    , 250, 250, 250, 250, 250, 250)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+303, netSellCostBuyPrice = netSellCostBuyPrice+250
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+250
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+250
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+250
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+250
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+250
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+250
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+250;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675ae745ac660 and sellbillId = 149174 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:20:58";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 16:50:58", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:50:58', '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-12 13:21:14";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 16:51:14", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:51:14', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149173');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:21:25";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 16:51:25", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:51:25', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149170');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:24:26";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:54:26", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:54:26', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245835
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9047,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-49' , clientdate = '2024-12-12 16:54:26', userid = '2' WHERE clientid = '9047';
UPDATE client SET  inUse = 0 where clientid = 9047;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9047','8081.00','8130','1','ايصال تحصيل (( قبض من عميل ))','245835', '-49', '2024-12-12 16:02:13', '2', 'clientPayedDeptController.php', '   ', '8130', '0', null, '0', null, null,'', '-1','1','1','8130','1','','3149','0');
UPDATE save SET  savecurrentvalue = '477439.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('469309.50','8130', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245858', '477439.5', '2024-12-12 16:54:26', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '8130', '8130', '2024-12-12', '2', '0', '0', '2024-12-12 16:54:26','اضافة ايصال سداد للعميل مي السويس  B503','1','0','0','0','245858','clientPayedDeptController.php?do=show&id=245858');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121732', '-1', '8130', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '8130', 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 ('121732', '-1', '8130', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-8130', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '9047', clientdebtchangebefore = '8081.000', clientdebtchangeamount = '8130.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245835', clientdebtchangeafter = '-49.000', clientdebtchangedate = '2024-12-12 16:02:13', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '8130.00',discount='', reciptid='0', dailyentryid = '121732',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='8130',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245858';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245835 -clientdebtchangeId = 245858
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245859
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245860
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10660,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12 16:55:05', userid = '2' WHERE clientid = '10660';
UPDATE client SET  inUse = 0 where clientid = 10660;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10660','522.00','522','1','ايصال تحصيل (( قبض من عميل ))','245860', '0', '2024-12-12 16:54:48', '2', 'clientPayedDeptController.php', '   ', '522', '0', null, '0', null, null,'', '-1','1','1','522','1','','3151','0');
UPDATE save SET  savecurrentvalue = '478678.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('478156.50','522', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245860', '478678.5', '2024-12-12 16:55:05', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '522', '522', '2024-12-12', '2', '0', '0', '2024-12-12 16:55:05','اضافة ايصال سداد للعميل سها سمير 41','1','0','0','0','245860','clientPayedDeptController.php?do=show&id=245860');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121734', '-1', '522', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '522', 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 ('121734', '12351', '522', '','0');
UPDATE accountstree SET name = 'سها سمير 41', customName = 'سها سمير 41', customNameEn = 'سها ىسمير 41', nameEn = 'سها ىسمير 41', parent = '58', accountNature = '0', theValue = '-722', theOrder = '0', layingOrder = '', reportid = '1', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-10 13:14:55' WHERE id = '12351';
UPDATE clientdebtchange SET clientid = '10660', clientdebtchangebefore = '522.000', clientdebtchangeamount = '522.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245860', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-12 16:54:48', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '522.00',discount='', reciptid='0', dailyentryid = '121734',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='522',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245860';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245861
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5689,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12 16:55:24', userid = '2' WHERE clientid = '5689';
UPDATE client SET  inUse = 0 where clientid = 5689;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5689','424.00','424','1','ايصال تحصيل (( قبض من عميل ))','245861', '0', '2024-12-12 16:55:06', '2', 'clientPayedDeptController.php', '   ', '424', '0', null, '0', null, null,'', '-1','1','1','424','1','','3152','0');
UPDATE save SET  savecurrentvalue = '479102.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('478678.50','424', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245861', '479102.5', '2024-12-12 16:55:24', '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-12', '2', '0', '0', '2024-12-12 16:55:24','اضافة ايصال سداد للعميل يارا صيام F101','1','0','0','0','245861','clientPayedDeptController.php?do=show&id=245861');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121735', '-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 ('121735', '-1', '424', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-424', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '5689', clientdebtchangebefore = '424.000', clientdebtchangeamount = '424.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245861', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-12 16:55:06', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '424.00',discount='', reciptid='0', dailyentryid = '121735',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='424',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245861';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675af852d251d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8548,@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-12 16:50:58', '0675af852d251d', '8548', '0.00', '4668', '150', '1', '4818.00', '4668', '0', '4668', '1', '2024-12-12 16:55:29', '', '75', '0', 'فوزي جابر طنطا M1', '2', '1', '3', '100', 'فوزي جابر طنطا M1', '13' ,'0','','','','','-1','0','0','0','0','0','4668','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '4668', userid = '75' WHERE clientid = '8548';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8548','0.00','4668','0','اضافة فاتورة مبيعات','149175', '4668', '2024-12-12 16:55:29', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '4668', '0', null, '0', null, null,'', '0','1','1','4668','1','2024-12-12 16:50:58','0','0');
UPDATE client SET  inUse = 0 where clientid = 8548;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35800;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07134', '149175', '5', '16160', '1', '300', '300', '0', '', '1', '2024-12-12 16:55:29', '16160', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35800-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 = 545091;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16160, '2024-12-12', 290.6600249066, 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.6600249066, 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-12', 290.6600249066, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290.6600249066, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '75', storedetaildate = '2024-12-12 16:55:29' WHERE storedetailid = '16159';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16160', '1', '1', '1', '149175', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '75', '2024-12-12 16:55:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35927;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07204', '149175', '5', '16303', '1', '320', '320', '0', '', '1', '2024-12-12 16:55:29', '16303', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35927-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 545092;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16303, '2024-12-12', 310.03735990037, 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.03735990037, 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-12', 310.03735990037, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310.03735990037, 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 = '12', userid = '75', storedetaildate = '2024-12-12 16:55:29' WHERE storedetailid = '16302';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16303', '1', '1', '1', '149175', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-12 16:55:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35324;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07010', '149175', '5', '15993', '1', '430', '430', '0', '', '1', '2024-12-12 16:55:30', '15993', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35324-1,','1','1','0','0','430','430','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
        , lastbuyprice_withTax = 350, meanbuyprice_withTax = 350, lastbuyprice_withDiscountAndTax = 350
                where sellbilldetailid = 545093;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15993, '2024-12-12', 416.61270236613, 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+416.61270236613, 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-12', 416.61270236613, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 350, 350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+416.61270236613, 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 = '4', userid = '75', storedetaildate = '2024-12-12 16:55:30' WHERE storedetailid = '15992';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15993', '1', '1', '1', '149175', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 16:55:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35957;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149175', '5', '16275', '1', '330', '330', '0', '', '1', '2024-12-12 16:55:30', '16275', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35957-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 = 282, lastbuyprice_withDiscountAndTax = 280
                where sellbilldetailid = 545094;
 INSERT INTO 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-12', 319.72602739726, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 280, 282, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+319.72602739726, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+281
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+281
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+282
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 319.72602739726, 280, 280
                    , 281, 280, 281, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 282, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+319.72602739726, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+281
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+281
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+280
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+280
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+282
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 16:55:30' WHERE storedetailid = '16274';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16275', '1', '1', '1', '149175', 'اضافة فاتورة مبيعات', 'sellbillController.php', '41', '40', '75', '2024-12-12 16:55:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35878;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149175', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-12 16:55:30', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35878-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 = 545095;
 INSERT INTO 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-12', 784.78206724782, 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+784.78206724782, 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-12', 784.78206724782, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0, 730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+784.78206724782, 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 = '69', userid = '75', storedetaildate = '2024-12-12 16:55:30' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '149175', 'اضافة فاتورة مبيعات', 'sellbillController.php', '70', '69', '75', '2024-12-12 16:55:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35543;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07105', '149175', '5', '16134', '1', '420', '420', '0', '', '1', '2024-12-12 16:55:30', '16134', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35543-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 = 545096;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16134, '2024-12-12', 406.92403486924, 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+406.92403486924, 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-12', 406.92403486924, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+406.92403486924, 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 = '4', userid = '75', storedetaildate = '2024-12-12 16:55:30' WHERE storedetailid = '16133';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16134', '1', '1', '1', '149175', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 16:55:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34593;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06695', '149175', '5', '15213', '1', '460', '460', '0', '', '1', '2024-12-12 16:55:30', '15213', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34593-1,','1','1','0','0','460','460','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 458.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 458.00
        , lastbuyprice_withTax = 450, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 450
                where sellbilldetailid = 545097;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15213, '2024-12-12', 445.67870485679, 460, 450
                    , 458, 450, 458, 451.11
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 450, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+445.67870485679, sellCostBuyPrice =sellCostBuyPrice+460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+458
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+458
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+451.11
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , 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-12', 445.67870485679, 460, 450
                    , 458, 450, 458, 451.11
                    , 0, 0, 0, 0
                    , 0, 0, 0, 450, 140, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+445.67870485679, sellCostBuyPrice =sellCostBuyPrice+460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+458
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+458
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+451.11
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+450
                            , 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 = '75', storedetaildate = '2024-12-12 16:55:30' WHERE storedetailid = '15212';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15213', '1', '1', '1', '149175', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-12 16:55:30','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', '149175', '5', '16193', '1', '600', '600', '0', '', '1', '2024-12-12 16:55:30', '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 = 545098;
 INSERT INTO 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-12', 581.3200498132, 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+581.3200498132, 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-12', 581.3200498132, 530, 530
                    , 530, 530, 530, 529.75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 530, 530, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+581.3200498132, 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 = '15', userid = '75', storedetaildate = '2024-12-12 16:55:30' WHERE storedetailid = '16192';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16193', '1', '1', '1', '149175', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16', '15', '75', '2024-12-12 16:55:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35858;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149175', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-12 16:55:30', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35858-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 = 545099;
 INSERT INTO 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-12', 465.05603985056, 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+465.05603985056, 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-12', 465.05603985056, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+465.05603985056, 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 = '106', userid = '75', storedetaildate = '2024-12-12 16:55:30' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '149175', 'اضافة فاتورة مبيعات', 'sellbillController.php', '107', '106', '75', '2024-12-12 16:55:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34628;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3264', '149175', '1', '15703', '1', '380', '380', '0', '', '1', '2024-12-12 16:55:30', '15703', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34628-1,','1','1','0','0','380','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
        , lastbuyprice_withTax = 320, meanbuyprice_withTax = 320, lastbuyprice_withDiscountAndTax = 320
                where sellbilldetailid = 545100;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15703, '2024-12-12', 368.16936488169, 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+368.16936488169, 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-12', 368.16936488169, 320, 320
                    , 320, 320, 320, 320
                    , 0, 0, 0, 0
                    , 0, 0, 0, 320, 320, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+368.16936488169, 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 = '10', userid = '75', storedetaildate = '2024-12-12 16:55:30' WHERE storedetailid = '15702';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15703', '1', '1', '1', '149175', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '75', '2024-12-12 16:55:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33584;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3091', '149175', '1', '14962', '1', '220', '220', '0', '', '1', '2024-12-12 16:55:30', '14962', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33584-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 = 545101;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14962, '2024-12-12', 213.15068493151, 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+213.15068493151, 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-12', 213.15068493151, 170, 170
                    , 170, 170, 170, 170
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+213.15068493151, 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 = '3', userid = '75', storedetaildate = '2024-12-12 16:55:30' WHERE storedetailid = '14961';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14962', '1', '1', '1', '149175', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-12 16:55: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', '149175', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 16:55:30', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149175', '17', '10291', '1', '48', '48', '0', '', '1', '2024-12-12 16:55:30', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','48','48','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 100 where clientid = 8548;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 4668, 4110, 4100
                    , 4109, 4100, 4109, 4100.86
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3930, 3622, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4668, sellCostBuyPrice =sellCostBuyPrice+4110
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4109
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4109
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+4100.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3930
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3622
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8548, '2024-12-12', 4668, 4110, 4100
                    , 4109, 4100, 4109, 4100.86
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,3930, 3622, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4668, sellCostBuyPrice =sellCostBuyPrice+4110
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4109
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4109
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+4100.86
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3930
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3622
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 4668, 4110, 4100
                    , 4109, 4100, 4109, 4100.86, 3930, 3622)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+4668, netSellCostBuyPrice = netSellCostBuyPrice+4110
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+4100
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+4109
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+4100
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+4109
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+4100.86
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+3930
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+3622;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af852d251d and sellbillId = 149175 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:25:31";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 16:55:31", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:55:31', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:25:46";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:55:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:55:46', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245862
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245862 -clientdebtchangeId = 245863
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:25:47";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:55:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:55:47', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:26:06";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:56:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:56:06', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245864
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:26:07";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:56:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:56:07', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:26:15";
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 productunit SET unitid = '1', productid = '15576', productnumber = '1.00', productunitdate = '2024-10-21', userid = '77', conditions = '0',proUnitParcode='1557601',proUnitSellAllPrice='300',proUnitSellHalfPrice='300',proUnitSellUnitPrice ='300',proUnitBuyPrice='240',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '15576';
UPDATE product SET productName = '6845', productDescription = '', productCatId = '5', productBuyPrice = '145', productSellAllPrice = '200', productSellUnitPrice = '200', productSellHalfPrice = '200', productDate = '2024-10-21', conditions = '0', userId = '77', limitamount = '1', parcode = '06845',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '240.00',lastbuyprice_withDiscount = '240',meanbuyprice = '193.5',meanbuyprice_withDiscount = '193.5' , productbuypricereal = '240' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='190',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='242',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 = '15576';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:26:27";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:56:27", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:56:27', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245865
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7529,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '35' , clientdate = '2024-12-12 16:56:27', userid = '2' WHERE clientid = '7529';
UPDATE client SET  inUse = 0 where clientid = 7529;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7529','535.00','500','1','ايصال تحصيل (( قبض من عميل ))','245865', '35', '2024-12-12 16:56:07', '2', 'clientPayedDeptController.php', '   ', '500', '0', null, '0', null, null,'', '-1','1','1','500','1','','3155','0');
UPDATE save SET  savecurrentvalue = '487569.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('487069.50','500', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245865', '487569.5', '2024-12-12 16:56:27', '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-12', '2', '0', '0', '2024-12-12 16:56:28','اضافة ايصال سداد للعميل رحمة السعيد U160','1','0','0','0','245865','clientPayedDeptController.php?do=show&id=245865');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121738', '-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 ('121738', '-1', '500', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-500', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '7529', clientdebtchangebefore = '535.000', clientdebtchangeamount = '500.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245865', clientdebtchangeafter = '35.000', clientdebtchangedate = '2024-12-12 16:56:07', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '500.00',discount='', reciptid='0', dailyentryid = '121738',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='500',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245865';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:26:28";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:56:28", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:56:28', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE productunit SET unitid = '1', productid = '15576', productnumber = '1.00', productunitdate = '2024-10-21', userid = '77', conditions = '0',proUnitParcode='1557601',proUnitSellAllPrice='300',proUnitSellHalfPrice='300',proUnitSellUnitPrice ='300',proUnitBuyPrice='240',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '15576';
UPDATE product SET productName = '6845', productDescription = '', productCatId = '5', productBuyPrice = '140', productSellAllPrice = '200', productSellUnitPrice = '200', productSellHalfPrice = '200', productDate = '2024-10-21', conditions = '0', userId = '77', limitamount = '1', parcode = '06845',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '240.00',lastbuyprice_withDiscount = '240',meanbuyprice = '166.75',meanbuyprice_withDiscount = '166.75' , productbuypricereal = '240' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='190',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='242',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 = '15576';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:26:47";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:56:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:56:47', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245866
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:26:48";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 16:56:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 16:56:48', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:27:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:57:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:57: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 0675af24ece29f
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9727,@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-12 16:25:18', '0675af24ece29f', '9727', '20.00', '1323', '20', '1', '1323.00', '1303', '0', '1303', '1', '2024-12-12 16:57:28', '', '104', '0', 'مني محمد الراعي 13', '1', '1', '3', '94', 'مني محمد الراعي 13', '6' ,'0','','','','','-1','0','0','0','0','0','1303','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1323', userid = '104' WHERE clientid = '9727';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9727','20.00','1303','0','اضافة فاتورة مبيعات','149176', '1323', '2024-12-12 16:57:28', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1303', '0', null, '0', null, null,'', '0','1','1','1303','1','2024-12-12 16:25:18','0','0');
UPDATE client SET  inUse = 0 where clientid = 9727;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35861;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','07187', '149176', '5', '16267', '1', '200', '200', '0', '', '1', '2024-12-12 16:57:28', '16267', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35861-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145, lastbuyprice_withDiscountAndTax = 145
                where sellbilldetailid = 545104;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16267, '2024-12-12', 196.97656840514, 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+196.97656840514, 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-12', 196.97656840514, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+196.97656840514, 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 = '104', storedetaildate = '2024-12-12 16:57:28' WHERE storedetailid = '16266';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16267', '1', '1', '1', '149176', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-12 16:57:28','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19220;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0H901', '149176', '14', '8988', '1', '330', '330', '0', '', '1', '2024-12-12 16:57:29', '8988', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','19220-1,','1','1','0','0','330','330','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 = 545105;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8988, '2024-12-12', 325.01133786848, 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+325.01133786848, 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-12', 325.01133786848, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+325.01133786848, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '104', storedetaildate = '2024-12-12 16:57:29' WHERE storedetailid = '8987';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('8988', '1', '1', '1', '149176', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-12 16:57:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32696;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0A304', '149176', '6', '14737', '1', '320', '320', '0', '', '1', '2024-12-12 16:57:29', '14737', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32696-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 270.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 270.00, meanbuyprice_withDiscount = 270.00
        
                where sellbilldetailid = 545106;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14737, '2024-12-12', 315.16250944822, 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+315.16250944822, 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-12', 315.16250944822, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+315.16250944822, 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 = '0', userid = '104', storedetaildate = '2024-12-12 16:57:29' WHERE storedetailid = '14736';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14737', '1', '1', '1', '149176', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-12 16:57:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35283;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07025', '149176', '5', '15964', '1', '210', '210', '0', '', '1', '2024-12-12 16:57:29', '15964', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35283-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 = 545107;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15964, '2024-12-12', 206.8253968254, 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+206.8253968254, 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-12', 206.8253968254, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 160, 160, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+206.8253968254, 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 = '4', userid = '104', storedetaildate = '2024-12-12 16:57:29' WHERE storedetailid = '15963';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15964', '1', '1', '1', '149176', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-12 16:57:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34912;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06941', '149176', '5', '15810', '1', '250', '250', '0', '', '1', '2024-12-12 16:57:29', '15810', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34912-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 190, lastbuyprice_withDiscountAndTax = 190
                where sellbilldetailid = 545108;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15810, '2024-12-12', 246.22071050642, 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+246.22071050642, 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-12', 246.22071050642, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+246.22071050642, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+190
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '104', storedetaildate = '2024-12-12 16:57:29' WHERE storedetailid = '15809';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15810', '1', '1', '1', '149176', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '104', '2024-12-12 16:57: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 ('0','10291', '149176', '17', '10291', '1', '13', '13', '0', '', '1', '2024-12-12 16:57:29', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','13','13','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 94 where clientid = 9727;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1303, 1015, 1015
                    , 1015, 1015, 1015, 1015
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1303, sellCostBuyPrice =sellCostBuyPrice+1015
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1015, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1015
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1015, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1015
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1015
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+495
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9727, '2024-12-12', 1303, 1015, 1015
                    , 1015, 1015, 1015, 1015
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,495, 495, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1303, sellCostBuyPrice =sellCostBuyPrice+1015
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1015, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1015
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1015, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1015
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1015
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+495
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1303, 1015, 1015
                    , 1015, 1015, 1015, 1015, 495, 495)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1303, netSellCostBuyPrice = netSellCostBuyPrice+1015
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1015
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1015
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1015
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1015
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1015
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+495
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+495;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af24ece29f and sellbillId = 149176 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675af9d99f74f
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5737,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate,qrerpid,qrerpids,autoSaveFlag,ereason,estatus,epdf,obgyBillType,billoperationid,datestarting,pricetype,currencyId,knownwayId,travelDriverId,travelBusId,travelPathId,travelTripId,travelTripTypeId,travelTripDateId,totalprodiscount,manage_ex,med_hallmark,pay_rec_no,pay_rec_val,decisionNo,decisionValue,sellToSupplier,supplierbuybillid) VALUES ('2024-12-12 16:57:29', '0675af9d99f74f', '5737', '662.00', '1313', '0', '1', '651.00', '651', '0', '651', '1', '2024-12-12 16:58:47', '', '101', '0', 'مريم حافظ 41', '2', '1', '3', '88', 'مريم حافظ 41', '3' ,'0','','','','','-1','0','0','0','0','0','651','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1313', userid = '101' WHERE clientid = '5737';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5737','662.00','651','0','اضافة فاتورة مبيعات','149177', '1313', '2024-12-12 16:58:47', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '651', '0', null, '0', null, null,'', '0','1','1','651','1','2024-12-12 16:57:29','0','0');
UPDATE client SET  inUse = 0 where clientid = 5737;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','05874', '149177', '5', '13105', '1', '165', '165', '0', '', '1', '2024-12-12 16:58:47', '13105', '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 = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        
                where sellbilldetailid = 545110;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13105, '2024-12-12', 165, 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+165, 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-12', 165, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, 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 = '0', userid = '101', storedetaildate = '2024-12-12 16:58:47' WHERE storedetailid = '13104';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13105', '1', '1', '1', '149177', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '101', '2024-12-12 16:58:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35858;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149177', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-12 16:58:47', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35858-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 = 545111;
 INSERT INTO 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-12', 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-12', 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 = '105', userid = '101', storedetaildate = '2024-12-12 16:58:47' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '149177', 'اضافة فاتورة مبيعات', 'sellbillController.php', '106', '105', '101', '2024-12-12 16:58: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 ('0','10291', '149177', '17', '10291', '1', '6', '6', '0', '', '1', '2024-12-12 16:58: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 = 88 where clientid = 5737;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 651, 685, 685
                    , 685, 685, 685, 685
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+651, sellCostBuyPrice =sellCostBuyPrice+685
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+685, sellCostMeanBuyPrice = sellCostMeanBuyPrice+685
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+685, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+685
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+685
                            , 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 (5737, '2024-12-12', 651, 685, 685
                    , 685, 685, 685, 685
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+651, sellCostBuyPrice =sellCostBuyPrice+685
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+685, sellCostMeanBuyPrice = sellCostMeanBuyPrice+685
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+685, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+685
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+685
                            , 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, 651, 685, 685
                    , 685, 685, 685, 685, 420, 420)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+651, netSellCostBuyPrice = netSellCostBuyPrice+685
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+685
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+685
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+685
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+685
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+685
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+420
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+420;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af9d99f74f and sellbillId = 149177 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:28:48";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:58:48", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:58:48', '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-12 13:28:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:58:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 16:58:48', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:29:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:59:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 16:59:07', '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-12', '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 = '25310',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('25360.00','50', '1', '1', 'إضافة مصروف', '25619', '25310', '2024-12-12 16:59:07', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'محمد عبدة', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25619';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:29:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:59:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 16:59:07', '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-12 13:29:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 16:59:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 16:59:09', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE productunit SET unitid = '1', productid = '15753', productnumber = '1.00', productunitdate = '2024-10-29', userid = '77', conditions = '0',proUnitParcode='1575301',proUnitSellAllPrice='320',proUnitSellHalfPrice='320',proUnitSellUnitPrice ='320',proUnitBuyPrice='260',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '15753';
UPDATE product SET productName = '6903', productDescription = '', productCatId = '5', productBuyPrice = '260', productSellAllPrice = '320', productSellUnitPrice = '320', productSellHalfPrice = '320', productDate = '2024-10-29', conditions = '0', userId = '77', limitamount = '1', parcode = '06903',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '260.00',lastbuyprice_withDiscount = '260',meanbuyprice = '260.00',meanbuyprice_withDiscount = '260' , productbuypricereal = '260' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='259.29',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='260',meanbuyprice_withTax='259',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='260'  WHERE productId = '15753';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:29:46";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 16:59:46", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 16:59: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-12 13:30:00";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:00:00", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:00:00', '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 = '15576', productnumber = '1.00', productunitdate = '2024-10-21', userid = '77', conditions = '0',proUnitParcode='1557601',proUnitSellAllPrice='300',proUnitSellHalfPrice='300',proUnitSellUnitPrice ='300',proUnitBuyPrice='240',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '15576';
UPDATE product SET productName = '6845', productDescription = '', productCatId = '5', productBuyPrice = '155', productSellAllPrice = '200', productSellUnitPrice = '200', productSellHalfPrice = '200', productDate = '2024-10-21', conditions = '0', userId = '77', limitamount = '1', parcode = '06845',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '240.00',lastbuyprice_withDiscount = '240',meanbuyprice = '160.88',meanbuyprice_withDiscount = '160.88' , productbuypricereal = '240' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='190',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='242',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 = '15576';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:30:46";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:00:46", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:00:46', '77', 'add', '192.168.1.73', '', '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 ('0675af62860ca0', '2024-12-12 16:41:44', '102', '165810.00', '198810', '0', '0', '33000',  '33000', '0', '33000', '1', '2024-12-12 17:00:46', '', '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 ('H1450', '14068', '14', '15831', '15', '265', '3975', '0', '', '2024-12-12 17:00:46', '15831','','','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-12 16:41:44', 1, 15831, 0, 0
                    , 265, 15, 0, 0, 77, '2024-12-12 17:00:46')
                ON DUPLICATE KEY UPDATE buyprice = 265,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:00:46' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15831', '265', '15', '0', 'buyBillController.php', '32530', '', '0', '0');
UPDATE product SET  productBuyPrice = "265" WHERE productId = 15831 ;
UPDATE buybilldetail SET  quantitybefore = -5 WHERE buybilldetailid = 32530 ;
UPDATE product SET productName = 'H1450', productDescription = '', productCatId = '14', productBuyPrice = '265.00', productSellAllPrice = '290.00', productSellUnitPrice = '290.00', productSellHalfPrice = '290.00', productDate = '2024-11-01', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1450',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '265',lastbuyprice_withDiscount = '265',meanbuyprice = '270',meanbuyprice_withDiscount = '270' , productbuypricereal = '290.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='245',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='275',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='265'  WHERE productId = '15831';
UPDATE buybilldetail SET  lastbuyprice = 265 , meanbuyprice = 270, lastbuyprice_withDiscount = 265, meanbuyprice_withDiscount = 270
        , lastbuyprice_withTax = 265, meanbuyprice_withTax = 275, lastbuyprice_withDiscountAndTax = 265
                where buybilldetailid = 32530;
UPDATE productunit SET proUnitBuyPrice  = 265 * productnumber WHERE productid = 15831;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15830';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15831', '1', '15', '0', '14068', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-5', '10', '77', '2024-12-12 16:41:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1529', '14068', '14', '16030', '10', '210', '2100', '0', '', '2024-12-12 17:00:46', '16030','','','0','0','0','0','0',null,'210','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-12 16:41:44', 1, 16030, 0, 0
                    , 210, 10, 0, 0, 77, '2024-12-12 17:00:46')
                ON DUPLICATE KEY UPDATE buyprice = 210,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:00:46' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16030', '210', '10', '0', 'buyBillController.php', '32531', '', '0', '0');
UPDATE product SET  productBuyPrice = "210" WHERE productId = 16030 ;
UPDATE buybilldetail SET  quantitybefore = -8 WHERE buybilldetailid = 32531 ;
UPDATE product SET productName = 'H1529', productDescription = '', productCatId = '14', productBuyPrice = '210.00', productSellAllPrice = '310.00', productSellUnitPrice = '310.00', productSellHalfPrice = '310.00', productDate = '2024-11-18', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1529',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 = '16030';
UPDATE buybilldetail SET  lastbuyprice = 210 , meanbuyprice = 210, lastbuyprice_withDiscount = 210, meanbuyprice_withDiscount = 210
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where buybilldetailid = 32531;
UPDATE productunit SET proUnitBuyPrice  = 210 * productnumber WHERE productid = 16030;
UPDATE storedetail SET  productquantity = '2', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16029';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16030', '1', '10', '0', '14068', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-8', '2', '77', '2024-12-12 16:41:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('88590', '14068', '5', '15996', '15', '170', '2550', '0', '', '2024-12-12 17:00:46', '15996','','','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-12 16:41:44', 1, 15996, 0, 0
                    , 170, 15, 0, 0, 77, '2024-12-12 17:00:46')
                ON DUPLICATE KEY UPDATE buyprice = 170,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:00:46' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15996', '170', '15', '0', 'buyBillController.php', '32532', '', '0', '0');
UPDATE product SET  productBuyPrice = "170" WHERE productId = 15996 ;
UPDATE buybilldetail SET  quantitybefore = -6 WHERE buybilldetailid = 32532 ;
UPDATE product SET productName = '7035', productDescription = '', productCatId = '5', productBuyPrice = '170.00', productSellAllPrice = '240.00', productSellUnitPrice = '240.00', productSellHalfPrice = '240.00', productDate = '2024-11-16', conditions = '0', userId = '77', limitamount = '0', parcode = '88590',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '170',lastbuyprice_withDiscount = '170',meanbuyprice = '175',meanbuyprice_withDiscount = '175' , 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='170',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='170',meanbuyprice_withTax='181',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='170'  WHERE productId = '15996';
UPDATE buybilldetail SET  lastbuyprice = 170 , meanbuyprice = 175, lastbuyprice_withDiscount = 170, meanbuyprice_withDiscount = 175
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 181, lastbuyprice_withDiscountAndTax = 170
                where buybilldetailid = 32532;
UPDATE productunit SET proUnitBuyPrice  = 170 * productnumber WHERE productid = 15996;
UPDATE storedetail SET  productquantity = '9', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15995';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15996', '1', '15', '0', '14068', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-6', '9', '77', '2024-12-12 16:41:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06411', '14068', '5', '14582', '15', '155', '2325', '0', '', '2024-12-12 17:00:46', '14582','','','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-12 16:41:44', 1, 14582, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-12 17:00:46')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:00:46' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('14582', '155', '15', '0', 'buyBillController.php', '32533', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 14582 ;
UPDATE buybilldetail SET  quantitybefore = -3 WHERE buybilldetailid = 32533 ;
UPDATE product SET productName = '6411', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '220.00', productSellUnitPrice = '220.00', productSellHalfPrice = '220.00', productDate = '2024-08-26', conditions = '0', userId = '77', limitamount = '1', parcode = '06411',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '153',meanbuyprice_withDiscount = '153' , productbuypricereal = '175.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='172.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='155',meanbuyprice_withTax='194',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 = '14582';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 153, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 153
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 194, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32533;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 14582;
UPDATE storedetail SET  productquantity = '12', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '14581';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14582', '1', '15', '0', '14068', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-3', '12', '77', '2024-12-12 16:41:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06845', '14068', '5', '15576', '15', '155', '2325', '0', '', '2024-12-12 17:00:46', '15576','','','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-12 16:41:44', 1, 15576, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-12 17:00:46')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:00:46' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15576', '155', '15', '0', 'buyBillController.php', '32534', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 15576 ;
UPDATE buybilldetail SET  quantitybefore = 1 WHERE buybilldetailid = 32534 ;
UPDATE product SET productName = '6845', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-10-21', conditions = '0', userId = '77', limitamount = '1', parcode = '06845',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '155',meanbuyprice_withDiscount = '155' , 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='190',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='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='155'  WHERE productId = '15576';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 160, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32534;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 15576;
UPDATE storedetail SET  productquantity = '16', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15575';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15576', '1', '15', '0', '14068', 'اضافة فاتورة مشتريات', 'buyBillController.php', '1', '16', '77', '2024-12-12 16:41:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07001', '14068', '5', '15970', '15', '140', '2100', '0', '', '2024-12-12 17:00:46', '15970','','','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-12 16:41:44', 1, 15970, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:00:46')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:00:46' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15970', '140', '15', '0', 'buyBillController.php', '32535', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 15970 ;
UPDATE buybilldetail SET  quantitybefore = -7 WHERE buybilldetailid = 32535 ;
UPDATE product SET productName = '7001', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-11-15', conditions = '0', userId = '77', limitamount = '1', parcode = '07001',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.62',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='151',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 = '15970';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 151, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32535;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 15970;
UPDATE storedetail SET  productquantity = '8', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15969';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15970', '1', '15', '0', '14068', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-7', '8', '77', '2024-12-12 16:41:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06987', '14068', '5', '15947', '15', '155', '2325', '0', '', '2024-12-12 17:00:46', '15947','','','0','0','0','0','0',null,'155','2325','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-12 16:41:44', 1, 15947, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-12 17:00:46')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:00:46' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15947', '155', '15', '0', 'buyBillController.php', '32536', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 15947 ;
UPDATE buybilldetail SET  quantitybefore = -1 WHERE buybilldetailid = 32536 ;
UPDATE product SET productName = '6987', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-11-11', conditions = '0', userId = '77', limitamount = '1', parcode = '06987',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '155',meanbuyprice_withDiscount = '155' , productbuypricereal = '150.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='155',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='155',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='155'  WHERE productId = '15947';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32536;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 15947;
UPDATE storedetail SET  productquantity = '14', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15946';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15947', '1', '15', '0', '14068', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-1', '14', '77', '2024-12-12 16:41:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06786', '14068', '5', '15389', '15', '155', '2325', '0', '', '2024-12-12 17:00:46', '15389','','','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-12 16:41:44', 1, 15389, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-12 17:00:46')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:00:46' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15389', '155', '15', '0', 'buyBillController.php', '32537', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 15389 ;
UPDATE buybilldetail SET  quantitybefore = -26 WHERE buybilldetailid = 32537 ;
UPDATE product SET productName = '6786', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-10-10', conditions = '0', userId = '77', limitamount = '1', parcode = '06786',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '162',meanbuyprice_withDiscount = '162' , 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='148.75',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='224',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 = '15389';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 162, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 162
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 224, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32537;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 15389;
UPDATE storedetail SET  productquantity = '-11', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15388';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15389', '1', '15', '0', '14068', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-26', '-11', '77', '2024-12-12 16:41:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06967', '14068', '5', '15924', '15', '155', '2325', '0', '', '2024-12-12 17:00:46', '15924','','','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-12 16:41:44', 1, 15924, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-12 17:00:46')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:00:46' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15924', '155', '15', '0', 'buyBillController.php', '32538', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 15924 ;
UPDATE buybilldetail SET  quantitybefore = -31 WHERE buybilldetailid = 32538 ;
UPDATE product SET productName = '6967', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '205.00', productSellUnitPrice = '205.00', productSellHalfPrice = '205.00', productDate = '2024-11-08', conditions = '0', userId = '77', limitamount = '1', parcode = '06967',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '155',meanbuyprice_withDiscount = '155' , productbuypricereal = '155.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='155',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='155',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='155'  WHERE productId = '15924';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32538;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 15924;
UPDATE storedetail SET  productquantity = '-16', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15923';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15924', '1', '15', '0', '14068', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-31', '-16', '77', '2024-12-12 16:41:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07019', '14068', '5', '15985', '15', '170', '2550', '0', '', '2024-12-12 17:00:46', '15985','','','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-12 16:41:44', 1, 15985, 0, 0
                    , 170, 15, 0, 0, 77, '2024-12-12 17:00:46')
                ON DUPLICATE KEY UPDATE buyprice = 170,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:00:46' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15985', '170', '15', '0', 'buyBillController.php', '32539', '', '0', '0');
UPDATE product SET  productBuyPrice = "170" WHERE productId = 15985 ;
UPDATE buybilldetail SET  quantitybefore = -1 WHERE buybilldetailid = 32539 ;
UPDATE product SET productName = '7019', productDescription = '', productCatId = '5', productBuyPrice = '170.00', productSellAllPrice = '230.00', productSellUnitPrice = '230.00', productSellHalfPrice = '230.00', productDate = '2024-11-16', conditions = '0', userId = '77', limitamount = '1', parcode = '07019',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='170',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 = '15985';
UPDATE buybilldetail SET  lastbuyprice = 170 , meanbuyprice = 170, lastbuyprice_withDiscount = 170, meanbuyprice_withDiscount = 170
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where buybilldetailid = 32539;
UPDATE productunit SET proUnitBuyPrice  = 170 * productnumber WHERE productid = 15985;
UPDATE storedetail SET  productquantity = '14', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15984';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15985', '1', '15', '0', '14068', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-1', '14', '77', '2024-12-12 16:41:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07051', '14068', '5', '16247', '15', '140', '2100', '0', '', '2024-12-12 17:00:46', '16247','','','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-12 16:41:44', 1, 16247, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:00:46')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:00:46' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16247', '140', '15', '0', 'buyBillController.php', '32540', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16247 ;
UPDATE buybilldetail SET  quantitybefore = -22 WHERE buybilldetailid = 32540 ;
UPDATE product SET productName = '7051', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-03', conditions = '0', userId = '77', limitamount = '0', parcode = '07051',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '234',meanbuyprice_withDiscount = '234' , 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='200',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='GS1',barcodeInTax='',productNameE='',partNumber='0',vehicleType='-1',company='-1',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='329',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '16247';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 234, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 234
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 329, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32540;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16247;
UPDATE storedetail SET  productquantity = '-7', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16246';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16247', '1', '15', '0', '14068', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-22', '-7', '77', '2024-12-12 16:41:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07043', '14068', '5', '16022', '15', '140', '2100', '0', '', '2024-12-12 17:00:46', '16022','','','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-12 16:41:44', 1, 16022, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:00:46')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:00:46' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16022', '140', '15', '0', 'buyBillController.php', '32541', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16022 ;
UPDATE buybilldetail SET  quantitybefore = -4 WHERE buybilldetailid = 32541 ;
UPDATE product SET productName = '7043', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-11-18', conditions = '0', userId = '77', limitamount = '1', parcode = '07043',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 = '16022';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32541;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16022;
UPDATE storedetail SET  productquantity = '11', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16021';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16022', '1', '15', '0', '14068', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-4', '11', '77', '2024-12-12 16:41:44','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06903', '14068', '5', '15753', '15', '260', '3900', '0', '', '2024-12-12 17:00:46', '15753','','','0','0','0','0','0',null,'260','3900','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-12 16:41:44', 1, 15753, 0, 0
                    , 260, 15, 0, 0, 77, '2024-12-12 17:00:46')
                ON DUPLICATE KEY UPDATE buyprice = 260,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:00:46' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15753', '260', '15', '0', 'buyBillController.php', '32542', '', '0', '0');
UPDATE product SET  productBuyPrice = "260" WHERE productId = 15753 ;
UPDATE buybilldetail SET  quantitybefore = -9 WHERE buybilldetailid = 32542 ;
UPDATE product SET productName = '6903', productDescription = '', productCatId = '5', productBuyPrice = '260.00', productSellAllPrice = '320.00', productSellUnitPrice = '320.00', productSellHalfPrice = '320.00', productDate = '2024-10-29', conditions = '0', userId = '77', limitamount = '1', parcode = '06903',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '260',lastbuyprice_withDiscount = '260',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '260.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='259.29',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='260',meanbuyprice_withTax='262',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='260'  WHERE productId = '15753';
UPDATE buybilldetail SET  lastbuyprice = 260 , meanbuyprice = 260, lastbuyprice_withDiscount = 260, meanbuyprice_withDiscount = 260
        , lastbuyprice_withTax = 260, meanbuyprice_withTax = 262, lastbuyprice_withDiscountAndTax = 260
                where buybilldetailid = 32542;
UPDATE productunit SET proUnitBuyPrice  = 260 * productnumber WHERE productid = 15753;
UPDATE storedetail SET  productquantity = '6', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15752';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15753', '1', '15', '0', '14068', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-9', '6', '77', '2024-12-12 16:41:44','0','0');
UPDATE supplier SET  suppliercurrentDebt = '198810',suppliercurrentDebtInCurrency= '198810' , userid = '77', supplierdate = '2024-12-12 17:00:46'   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', '165810.00', '33000', '0', 'اضافة فاتورة مشتريات', '14068', '198810', '2024-12-12 16:41:44', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','33000','1','165810','33000','198810','0');
update buybill set dailyentryid='0,' where buybillid=14068;
COMMIT;
UPDATE product SET overAllAveragePrice = 166.67 WHERE productId = 14582;UPDATE product SET overAllAveragePrice = 150 WHERE productId = 15389;UPDATE product SET overAllAveragePrice = 184.17 WHERE productId = 15576;UPDATE product SET overAllAveragePrice = 259.38 WHERE productId = 15753;UPDATE product SET overAllAveragePrice = 252.5 WHERE productId = 15831;UPDATE product SET overAllAveragePrice = 155 WHERE productId = 15924;UPDATE product SET overAllAveragePrice = 155 WHERE productId = 15947;UPDATE product SET overAllAveragePrice = 140.56 WHERE productId = 15970;UPDATE product SET overAllAveragePrice = 170 WHERE productId = 15985;UPDATE product SET overAllAveragePrice = 170 WHERE productId = 15996;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16022;UPDATE product SET overAllAveragePrice = 210 WHERE productId = 16030;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16247;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:30:47";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:00:47", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:00:47', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14068');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:30:53";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:00:53", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:00:53', '101', 'editsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=149177');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:31:09";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:01:09", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:01:09', '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 = 149177 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


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

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 149177;
UPDATE sellbill SET  sellbillsysdate = '2024-12-12 17:01:09', userid = '101',delbyuserid = '101', conditions = '1'  WHERE sellbillid = '149177';
UPDATE sellbilldetail SET  lastbuyprice = 265.00 , meanbuyprice = 265.00, lastbuyprice_withDiscount = 265.00, meanbuyprice_withDiscount = 265.00
        
                where sellbilldetailid = 545110;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13105, '2024-12-12', 165, 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-165, 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-12', 165, 265, 265
                    , 265, 265, 265, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-165, 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 = '1', userid = '101', storedetaildate = '2024-12-12 17:01:09' WHERE storedetailid = '13104';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13105', '1', '1', '0', '149177', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0', '1', '101', '2024-12-12 16:57:29','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35858;
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 = 545111;
 INSERT INTO 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-12', 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-12', 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 = '106', userid = '101', storedetaildate = '2024-12-12 17:01:09' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '0', '149177', 'تعديل فاتورة مبيعات', 'sellbillController.php', '105', '106', '101', '2024-12-12 16:57:29','0','0');
CALL clientInUse(5737,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '662', userid = '101' WHERE clientid = '5737';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5737','1313.00','651.00','1','تعديل فاتورة مبيعات','149177', '662', '2024-12-12 16:57:29', '101', 'sellbillController.php', 'تعديل فاتورة مبيعات', '651', '0', null, '0', null, null,'', '0','1','1','651','1','2024-12-12 16:57:29','0','0');
UPDATE client SET  inUse = 0 where clientid = 5737;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 651, 685, 685
                    , 685, 685, 685, 685
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-651, sellCostBuyPrice =sellCostBuyPrice-685
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-685, sellCostMeanBuyPrice = sellCostMeanBuyPrice-685
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-685, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-685
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-685
                            , 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 (5737, '2024-12-12', 651, 685, 685
                    , 685, 685, 685, 685
                    , 0, 0, 0, 0
                    , 0, 0, 0, 420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-651, sellCostBuyPrice =sellCostBuyPrice-685
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-685, sellCostMeanBuyPrice = sellCostMeanBuyPrice-685
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-685, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-685
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-685
                            , 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, 651, 685, 685
                    , 685, 685, 685, 685, 420, 420)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-651, netSellCostBuyPrice = netSellCostBuyPrice-685
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-685
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-685
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-685
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-685
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-685
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-420
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-420;

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


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

COMMIT;
BEGIN;
CALL clientInUse(5737,@clientdebt,@clientname,@treeIdis);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,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-12 16:57:29', '0675af9d99f74f', '5737', '662.00', '1147', '0', '1', '485', '485', '0', '485', '1', '2024-12-12 16:57:29', '', '101', '0', 'مريم حافظ 41', '2', '1', '3', '88', 'مريم حافظ 41', '2', '149177', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1147', userid = '101' WHERE clientid = '5737';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5737','662.00','485','0','اضافة فاتورة مبيعات (معدله)','149178', '1147', '2024-12-12 17:01:09', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '485', '0', null, '0', null, null,'', '0','1','1','651','1','2024-12-12 16:57:29','0','0');
UPDATE client SET  inUse = 0 where clientid = 5737;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35858;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149178', '5', '15995', '1', '480', '480', '0', '', '1', '2024-12-12 17:01:09', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35858-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 = 545113;
 INSERT INTO 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-12', 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-12', 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 = '105', userid = '101', storedetaildate = '2024-12-12 17:01:09' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '1', '1', '149178', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '106', '105', '101', '2024-12-12 17:01: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', '149178', '17', '10291', '1', '5', '5', '0', '', '1', '2024-12-12 17:01:09', '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');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 485, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+485, 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 (5737, '2024-12-12', 485, 420, 420
                    , 420, 420, 420, 420
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,420, 420, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+485, 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, 485, 420, 420
                    , 420, 420, 420, 420, 420, 420)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+485, 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 update end - new add end - with oldid = 149177 and newid=149178 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:31:09";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:01:09", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:01:09', '101', 'editprint', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=149178');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:31:46";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:01:46", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:01:46', '77', 'bill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:31:59";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 17:01:59", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 17:01:59', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:32:12";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 17:02:12", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 17:02:12', '2', 'add', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =4064
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4064,@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 ('4064','171.00','171','1','تسوية عجز عميل بالخصم','-1', '0', '2024-12-12 17:02:12', '2', 'clientDeficitController.php', '', '171', '0', null, '0', null, null,'', '0','1','1','171','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12', userid = '2' WHERE clientid = '4064';
UPDATE client SET  inUse = 0 where clientid = 4064;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =4064 ,id=245871
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245867
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245867 -clientdebtchangeId = 245872
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245873
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4190,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-4' , clientdate = '2024-12-12 17:03:10', userid = '2' WHERE clientid = '4190';
UPDATE client SET  inUse = 0 where clientid = 4190;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4190','1516.00','1520','1','ايصال تحصيل (( قبض من عميل ))','245873', '-4', '2024-12-12 17:02:51', '2', 'clientPayedDeptController.php', '   ', '1520', '0', null, '0', null, null,'', '-1','1','1','1520','1','','3158','0');
UPDATE save SET  savecurrentvalue = '492160.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('490640.50','1520', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245873', '492160.5', '2024-12-12 17:03:10', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1520', '1520', '2024-12-12', '2', '0', '0', '2024-12-12 17:03:10','اضافة ايصال سداد للعميل احمد حنفي اسوان i228','1','0','0','0','245873','clientPayedDeptController.php?do=show&id=245873');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121741', '-1', '1520', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1520', 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 ('121741', '-1', '1520', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1520', 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 = '4190', clientdebtchangebefore = '1516.000', clientdebtchangeamount = '1520.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245873', clientdebtchangeafter = '-4.000', clientdebtchangedate = '2024-12-12 17:02:51', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1520.00',discount='', reciptid='0', dailyentryid = '121741',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1520',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245873';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245874
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4708,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12 17:03:29', userid = '2' WHERE clientid = '4708';
UPDATE client SET  inUse = 0 where clientid = 4708;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4708','1682.00','1682','1','ايصال تحصيل (( قبض من عميل ))','245874', '0', '2024-12-12 17:03:10', '2', 'clientPayedDeptController.php', '   ', '1682', '0', null, '0', null, null,'', '-1','1','1','1682','1','','3159','0');
UPDATE save SET  savecurrentvalue = '493842.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('492160.50','1682', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245874', '493842.5', '2024-12-12 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 ( '1682', '1682', '2024-12-12', '2', '0', '0', '2024-12-12 17:03:29','اضافة ايصال سداد للعميل شروق عبد الغني B1424','1','0','0','0','245874','clientPayedDeptController.php?do=show&id=245874');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121742', '-1', '1682', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1682', 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 ('121742', '-1', '1682', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1682', 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 = '4708', clientdebtchangebefore = '1682.000', clientdebtchangeamount = '1682.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245874', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-12 17:03:10', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1682.00',discount='', reciptid='0', dailyentryid = '121742',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1682',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245874';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245875
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9770,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-620' , clientdate = '2024-12-12 17:04:06', userid = '2' WHERE clientid = '9770';
UPDATE client SET  inUse = 0 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','0.00','620','1','ايصال تحصيل (( قبض من عميل ))','245875', '-620', '2024-12-12 17:03:30', '2', 'clientPayedDeptController.php', '   ', '620', '0', null, '0', null, null,'', '-1','1','1','620','1','','3160','0');
UPDATE save SET  savecurrentvalue = '494462.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('493842.50','620', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245875', '494462.5', '2024-12-12 17:04:06', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('نوسا الغيط 41', 'نوسا الغيط 41', 'نوسا الغيط 41', 'نوسا الغيط 41', '58', '0', '-620.00', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-12 17:04:06');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '620', '620', '2024-12-12', '2', '0', '0', '2024-12-12 17:04:06','اضافة ايصال سداد للعميل نوسا الغيط 41','1','0','0','0','245875','clientPayedDeptController.php?do=show&id=245875');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121743', '-1', '620', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '620', 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 ('121743', '12423', '620', '','0');
UPDATE accountstree SET name = 'نوسا الغيط 41', customName = 'نوسا الغيط 41', customNameEn = 'نوسا الغيط 41', nameEn = 'نوسا الغيط 41', parent = '58', accountNature = '0', theValue = '-1240', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-12 17:04:06' WHERE id = '12423';
UPDATE clientdebtchange SET clientid = '9770', clientdebtchangebefore = '0.000', clientdebtchangeamount = '620.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245875', clientdebtchangeafter = '-620.000', clientdebtchangedate = '2024-12-12 17:03:30', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '620.00',discount='', reciptid='0', dailyentryid = '121743',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='620',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245875';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:34:07";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:04:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:04:07', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:34:08";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:04:08", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:04:08', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675af81e58c3b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9583,@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-12 16:50:06', '0675af81e58c3b', '9583', '0.00', '1348', '0', '1', '1348.00', '1348', '0', '1348', '1', '2024-12-12 17:04:08', '', '101', '0', 'هبه مجدي 13', '2', '1', '3', '82', 'هبه مجدي 13', '12' ,'0','','','','','-1','0','0','0','0','0','1348','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1348', userid = '101' WHERE clientid = '9583';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9583','0.00','1348','0','اضافة فاتورة مبيعات','149179', '1348', '2024-12-12 17:04:08', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1348', '0', null, '0', null, null,'', '0','1','1','1348','1','2024-12-12 16:50:06','0','0');
UPDATE client SET  inUse = 0 where clientid = 9583;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('100','عرض 100', '149179', '18', '10345', '3', '100', '300', '0', '', '1', '2024-12-12 17:04:08', '10345', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','100','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 100.00 , meanbuyprice = 100.00, lastbuyprice_withDiscount = 100.00, meanbuyprice_withDiscount = 100.00
        
                where sellbilldetailid = 545115;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10345, '2024-12-12', 300, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 300, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+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 = '-100', userid = '101', storedetaildate = '2024-12-12 17:04:08' WHERE storedetailid = '10344';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10345', '1', '3', '1', '149179', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-97', '-100', '101', '2024-12-12 17:04: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 ('150','عرض 150', '149179', '18', '10355', '1', '150', '150', '0', '', '1', '2024-12-12 17:04:08', '10355', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','150','150','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 150.00 , meanbuyprice = 150.00, lastbuyprice_withDiscount = 150.00, meanbuyprice_withDiscount = 150.00
        
                where sellbilldetailid = 545116;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10355, '2024-12-12', 150, 150, 150
                    , 150, 150, 150, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 150, 150, 150
                    , 150, 150, 150, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+150, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-111', userid = '101', storedetaildate = '2024-12-12 17:04:08' WHERE storedetailid = '10354';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('10355', '1', '1', '1', '149179', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-110', '-111', '101', '2024-12-12 17:04:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32324;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2899', '149179', '1', '14366', '1', '185', '185', '0', '', '1', '2024-12-12 17:04:08', '14366', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32324-1,','1','1','0','0','185','185','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 1735.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 1735.00
        
                where sellbilldetailid = 545117;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14366, '2024-12-12', 185, 190, 190
                    , 1735, 190, 1735, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1735
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1735
                            , 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-12', 185, 190, 190
                    , 1735, 190, 1735, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1735
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1735
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '101', storedetaildate = '2024-12-12 17:04:08' WHERE storedetailid = '14365';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14366', '1', '1', '1', '149179', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '101', '2024-12-12 17:04: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 ('190','06643', '149179', '5', '15126', '1', '205', '205', '0', '', '1', '2024-12-12 17:04:08', '15126', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','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 = 545118;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15126, '2024-12-12', 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-12', 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 = '0', userid = '101', storedetaildate = '2024-12-12 17:04:08' WHERE storedetailid = '15125';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15126', '1', '1', '1', '149179', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '101', '2024-12-12 17:04:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32713;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('85','R2867', '149179', '1', '14243', '1', '55', '55', '0', '', '1', '2024-12-12 17:04:08', '14243', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32713-1,','1','1','0','0','55','55','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 85.00 , meanbuyprice = 85.00, lastbuyprice_withDiscount = 85.00, meanbuyprice_withDiscount = 85.00
        
                where sellbilldetailid = 545119;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14243, '2024-12-12', 55, 85, 85
                    , 85, 85, 85, 85
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+55, sellCostBuyPrice =sellCostBuyPrice+85
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+85, sellCostMeanBuyPrice = sellCostMeanBuyPrice+85
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+85, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+85
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+85
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 55, 85, 85
                    , 85, 85, 85, 85
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+55, sellCostBuyPrice =sellCostBuyPrice+85
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+85, sellCostMeanBuyPrice = sellCostMeanBuyPrice+85
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+85, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+85
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+85
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 17:04:08' WHERE storedetailid = '14242';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14243', '1', '1', '1', '149179', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '101', '2024-12-12 17:04: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 ('220','06507', '149179', '5', '14858', '1', '180', '180', '0', '', '1', '2024-12-12 17:04:08', '14858', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','180','180','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 220.00 , meanbuyprice = 220.00, lastbuyprice_withDiscount = 220.00, meanbuyprice_withDiscount = 220.00
        
                where sellbilldetailid = 545120;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14858, '2024-12-12', 180, 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+180, 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-12', 180, 220, 220
                    , 220, 220, 220, 220
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+180, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+220, sellCostMeanBuyPrice = sellCostMeanBuyPrice+220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+220, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+220
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+220
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '101', storedetaildate = '2024-12-12 17:04:08' WHERE storedetailid = '14857';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14858', '1', '1', '1', '149179', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '101', '2024-12-12 17:04:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34613;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06839', '149179', '5', '15567', '1', '120', '120', '0', '', '1', '2024-12-12 17:04:08', '15567', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34613-1,','1','1','0','0','120','120','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 175.00 , meanbuyprice = 172.00, lastbuyprice_withDiscount = 175.00, meanbuyprice_withDiscount = 172.00
        , lastbuyprice_withTax = 175, meanbuyprice_withTax = 73, lastbuyprice_withDiscountAndTax = 175
                where sellbilldetailid = 545121;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15567, '2024-12-12', 120, 175, 175
                    , 172, 175, 172, 171.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 175, 73, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+172
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+172
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+171.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+175
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+73
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 120, 175, 175
                    , 172, 175, 172, 171.67
                    , 0, 0, 0, 0
                    , 0, 0, 0, 175, 73, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+175
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+175, sellCostMeanBuyPrice = sellCostMeanBuyPrice+172
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+175, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+172
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+171.67
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+175
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+73
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '101', storedetaildate = '2024-12-12 17:04:08' WHERE storedetailid = '15566';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15567', '1', '1', '1', '149179', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '101', '2024-12-12 17:04:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34547;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06843', '149179', '5', '15568', '1', '120', '120', '0', '', '1', '2024-12-12 17:04:08', '15568', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34547-1,','1','1','0','0','120','120','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 159.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 159.00
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 120, lastbuyprice_withDiscountAndTax = 160
                where sellbilldetailid = 545122;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15568, '2024-12-12', 120, 160, 160
                    , 159, 160, 159, 158.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 160, 120, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+159
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+159
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+158.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+120
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 120, 160, 160
                    , 159, 160, 159, 158.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 160, 120, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+159
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+159
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+158.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+120
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '101', storedetaildate = '2024-12-12 17:04:08' WHERE storedetailid = '15567';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15568', '1', '1', '1', '149179', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '101', '2024-12-12 17:04: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', '149179', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 17:04: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', '149179', '17', '10291', '1', '13', '13', '0', '', '1', '2024-12-12 17:04:09', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','13','13','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 82 where clientid = 9583;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1348, 1470, 1470
                    , 3011, 1470, 3011, 1015
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 193, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1348, sellCostBuyPrice =sellCostBuyPrice+1470
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1470, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3011
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1470, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3011
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1015
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+193
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9583, '2024-12-12', 1348, 1470, 1470
                    , 3011, 1470, 3011, 1015
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,335, 193, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1348, sellCostBuyPrice =sellCostBuyPrice+1470
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1470, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3011
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1470, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3011
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1015
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+193
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1348, 1470, 1470
                    , 3011, 1470, 3011, 1015, 335, 193)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1348, netSellCostBuyPrice = netSellCostBuyPrice+1470
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1470
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+3011
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1470
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+3011
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1015
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+335
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+193;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af81e58c3b and sellbillId = 149179 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675af9636814a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8692,@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-12 16:55:31', '0675af9636814a', '8692', '20.00', '459', '0', '1', '439.00', '439', '0', '439', '1', '2024-12-12 17:04:55', '', '75', '0', 'ام فهد M9', '2', '1', '3', '52', 'ام فهد M9', '4' ,'0','','','','','-1','0','0','0','0','0','439','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '459', userid = '75' WHERE clientid = '8692';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8692','20.00','439','0','اضافة فاتورة مبيعات','149180', '459', '2024-12-12 17:04:55', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '439', '0', null, '0', null, null,'', '0','1','1','439','1','2024-12-12 16:55:31','0','0');
UPDATE client SET  inUse = 0 where clientid = 8692;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36041;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07093', '149180', '5', '16084', '1', '185', '185', '0', '', '1', '2024-12-12 17:04:55', '16084', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36041-1,','1','1','0','0','185','185','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 = 545125;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16084, '2024-12-12', 185, 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+185, 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-12', 185, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+185, sellCostBuyPrice =sellCostBuyPrice+145
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+145, sellCostMeanBuyPrice = sellCostMeanBuyPrice+145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+145, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+145
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+145
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+145
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+145
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '75', storedetaildate = '2024-12-12 17:04:55' WHERE storedetailid = '16083';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16084', '1', '1', '1', '149180', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 17:04:55','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35210;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06808', '149180', '5', '15490', '1', '230', '230', '0', '', '1', '2024-12-12 17:04:55', '15490', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35210-1,','1','1','0','0','230','230','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 239.00, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 239.00
        , lastbuyprice_withTax = 235, meanbuyprice_withTax = 99, lastbuyprice_withDiscountAndTax = 235
                where sellbilldetailid = 545126;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15490, '2024-12-12', 230, 235, 235
                    , 239, 235, 239, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 235, 99, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+239
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+99
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 230, 235, 235
                    , 239, 235, 239, 237.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 235, 99, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+239
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+239
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+237.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+235
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+99
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 17:04:55' WHERE storedetailid = '15489';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15490', '1', '1', '1', '149180', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-12 17:04:55','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149180', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 17:04:55', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149180', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-12 17:04:55', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','4','4','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 52 where clientid = 8692;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 439, 380, 380
                    , 384, 380, 384, 382.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,380, 244, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+439, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+384
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+384
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+382.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+244
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8692, '2024-12-12', 439, 380, 380
                    , 384, 380, 384, 382.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,380, 244, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+439, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+384
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+384
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+382.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+380
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+244
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 439, 380, 380
                    , 384, 380, 384, 382.5, 380, 244)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+439, netSellCostBuyPrice = netSellCostBuyPrice+380
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+380
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+384
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+380
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+384
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+382.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+380
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+244;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af9636814a and sellbillId = 149180 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:34:56";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 17:04:56", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:04:56', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE productunit SET unitid = '1', productid = '15742', productnumber = '1.00', productunitdate = '2024-10-29', userid = '77', conditions = '0',proUnitParcode='1574201',proUnitSellAllPrice='250',proUnitSellHalfPrice='250',proUnitSellUnitPrice ='250',proUnitBuyPrice='200',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '15742';
UPDATE product SET productName = 'R3269', productDescription = '', productCatId = '1', productBuyPrice = '165', productSellAllPrice = '250', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2024-10-29', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3269',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '200.00',lastbuyprice_withDiscount = '200',meanbuyprice = '182.5',meanbuyprice_withDiscount = '182.5' , productbuypricereal = '200' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='200',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='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='200'  WHERE productId = '15742';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:35:23";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:05:23", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:05:23', '77', 'add', '192.168.1.73', '', '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 ('0675afada7e71c', '2024-12-12 17:01:46', '102', '198810.00', '227410', '0', '0', '28600',  '28600', '0', '28600', '1', '2024-12-12 17:05: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 ('H1470', '14069', '14', '15887', '20', '215', '4300', '0', '', '2024-12-12 17:05:23', '15887','','','0','0','0','0','0',null,'215','4300','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-12 17:01:46', 1, 15887, 0, 0
                    , 215, 20, 0, 0, 77, '2024-12-12 17:05:23')
                ON DUPLICATE KEY UPDATE buyprice = 215,
                        buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:05:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15887', '215', '20', '0', 'buyBillController.php', '32543', '', '0', '0');
UPDATE product SET  productBuyPrice = "215" WHERE productId = 15887 ;
UPDATE buybilldetail SET  quantitybefore = -11 WHERE buybilldetailid = 32543 ;
UPDATE product SET productName = 'H1470', productDescription = '', productCatId = '14', productBuyPrice = '215.00', productSellAllPrice = '280.00', productSellUnitPrice = '280.00', productSellHalfPrice = '280.00', productDate = '2024-11-06', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1470',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '215',lastbuyprice_withDiscount = '215',meanbuyprice = '169',meanbuyprice_withDiscount = '169' , 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='215',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='215',meanbuyprice_withTax='123',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='215'  WHERE productId = '15887';
UPDATE buybilldetail SET  lastbuyprice = 215 , meanbuyprice = 169, lastbuyprice_withDiscount = 215, meanbuyprice_withDiscount = 169
        , lastbuyprice_withTax = 215, meanbuyprice_withTax = 123, lastbuyprice_withDiscountAndTax = 215
                where buybilldetailid = 32543;
UPDATE productunit SET proUnitBuyPrice  = 215 * productnumber WHERE productid = 15887;
UPDATE storedetail SET  productquantity = '9', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15886';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15887', '1', '20', '0', '14069', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-11', '9', '77', '2024-12-12 17:01:46','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 ('06786', '14069', '5', '15389', '15', '155', '2325', '0', '', '2024-12-12 17:05:23', '15389','','','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-12 17:01:46', 1, 15389, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-12 17:05:23')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:05:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15389', '155', '15', '0', 'buyBillController.php', '32544', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 15389 ;
UPDATE buybilldetail SET  quantitybefore = -11 WHERE buybilldetailid = 32544 ;
UPDATE product SET productName = '6786', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-10-10', conditions = '0', userId = '77', limitamount = '1', parcode = '06786',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '136',meanbuyprice_withDiscount = '136' , 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='150',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='35',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 = '15389';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 136, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 136
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 35, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32544;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 15389;
UPDATE storedetail SET  productquantity = '4', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15388';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15389', '1', '15', '0', '14069', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-11', '4', '77', '2024-12-12 17:01:46','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', '14069', '5', '15856', '15', '140', '2100', '0', '', '2024-12-12 17:05:23', '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-12 17:01:46', 1, 15856, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:05:23')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:05:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15856', '140', '15', '0', 'buyBillController.php', '32545', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 15856 ;
UPDATE buybilldetail SET  quantitybefore = -7 WHERE buybilldetailid = 32545 ;
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 = 32545;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 15856;
UPDATE storedetail SET  productquantity = '8', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15855';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15856', '1', '15', '0', '14069', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-7', '8', '77', '2024-12-12 17:01:46','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', '14069', '5', '15821', '15', '140', '2100', '0', '', '2024-12-12 17:05:23', '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-12 17:01:46', 1, 15821, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:05:23')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:05:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15821', '140', '15', '0', 'buyBillController.php', '32546', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 15821 ;
UPDATE buybilldetail SET  quantitybefore = -8 WHERE buybilldetailid = 32546 ;
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 = '143',meanbuyprice_withDiscount = '143' , 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.67',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='140',meanbuyprice_withTax='149',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 = 143, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 143
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 149, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32546;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 15821;
UPDATE storedetail SET  productquantity = '7', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15820';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15821', '1', '15', '0', '14069', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-8', '7', '77', '2024-12-12 17:01:46','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 ('R3285', '14069', '1', '15934', '15', '165', '2475', '0', '', '2024-12-12 17:05:23', '15934','','','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-12 17:01:46', 1, 15934, 0, 0
                    , 165, 15, 0, 0, 77, '2024-12-12 17:05:23')
                ON DUPLICATE KEY UPDATE buyprice = 165,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:05:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15934', '165', '15', '0', 'buyBillController.php', '32547', '', '0', '0');
UPDATE product SET  productBuyPrice = "165" WHERE productId = 15934 ;
UPDATE buybilldetail SET  quantitybefore = -13 WHERE buybilldetailid = 32547 ;
UPDATE product SET productName = 'R3285', productDescription = '', productCatId = '1', productBuyPrice = '165.00', productSellAllPrice = '210.00', productSellUnitPrice = '210.00', productSellHalfPrice = '210.00', productDate = '2024-11-08', conditions = '0', userId = '77', limitamount = '0', parcode = 'R3285',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 = '27.27' , 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='GS1',barcodeInTax='',productNameE='',partNumber='0',vehicleType='-1',company='-1',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='1',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='-1',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='165'  WHERE productId = '15934';
UPDATE buybilldetail SET  lastbuyprice = 165 , meanbuyprice = 165, lastbuyprice_withDiscount = 165, meanbuyprice_withDiscount = 165
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 165, lastbuyprice_withDiscountAndTax = 165
                where buybilldetailid = 32547;
UPDATE productunit SET proUnitBuyPrice  = 165 * productnumber WHERE productid = 15934;
UPDATE storedetail SET  productquantity = '2', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15933';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15934', '1', '15', '0', '14069', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-13', '2', '77', '2024-12-12 17:01:46','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 ('R3269', '14069', '1', '15742', '15', '165', '2475', '0', '', '2024-12-12 17:05:23', '15742','','','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-12 17:01:46', 1, 15742, 0, 0
                    , 165, 15, 0, 0, 77, '2024-12-12 17:05:23')
                ON DUPLICATE KEY UPDATE buyprice = 165,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:05:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15742', '165', '15', '0', 'buyBillController.php', '32548', '', '0', '0');
UPDATE product SET  productBuyPrice = "165" WHERE productId = 15742 ;
UPDATE buybilldetail SET  quantitybefore = -13 WHERE buybilldetailid = 32548 ;
UPDATE product SET productName = 'R3269', productDescription = '', productCatId = '1', productBuyPrice = '165.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '250.00', productDate = '2024-10-29', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3269',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '165',lastbuyprice_withDiscount = '165',meanbuyprice = '51',meanbuyprice_withDiscount = '51' , 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='200',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='588',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 = '15742';
UPDATE buybilldetail SET  lastbuyprice = 165 , meanbuyprice = 51, lastbuyprice_withDiscount = 165, meanbuyprice_withDiscount = 51
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 588, lastbuyprice_withDiscountAndTax = 165
                where buybilldetailid = 32548;
UPDATE productunit SET proUnitBuyPrice  = 165 * productnumber WHERE productid = 15742;
UPDATE storedetail SET  productquantity = '2', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15741';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15742', '1', '15', '0', '14069', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-13', '2', '77', '2024-12-12 17:01:46','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 ('06967', '14069', '5', '15924', '15', '155', '2325', '0', '', '2024-12-12 17:05:23', '15924','','','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-12 17:01:46', 1, 15924, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-12 17:05:23')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:05:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15924', '155', '15', '0', 'buyBillController.php', '32549', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 15924 ;
UPDATE buybilldetail SET  quantitybefore = -16 WHERE buybilldetailid = 32549 ;
UPDATE product SET productName = '6967', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '205.00', productSellUnitPrice = '205.00', productSellHalfPrice = '205.00', productDate = '2024-11-08', conditions = '0', userId = '77', limitamount = '1', parcode = '06967',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '155',meanbuyprice_withDiscount = '155' , productbuypricereal = '155.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='155',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='155',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='155'  WHERE productId = '15924';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32549;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 15924;
UPDATE storedetail SET  productquantity = '-1', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15923';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15924', '1', '15', '0', '14069', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-16', '-1', '77', '2024-12-12 17:01:46','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 ('06935', '14069', '5', '15812', '15', '155', '2325', '0', '', '2024-12-12 17:05:23', '15812','','','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-12 17:01:46', 1, 15812, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-12 17:05:23')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:05:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15812', '155', '15', '0', 'buyBillController.php', '32550', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 15812 ;
UPDATE buybilldetail SET  quantitybefore = -14 WHERE buybilldetailid = 32550 ;
UPDATE product SET productName = '6935', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '210.00', productSellUnitPrice = '210.00', productSellHalfPrice = '210.00', productDate = '2024-10-31', conditions = '0', userId = '77', limitamount = '1', parcode = '06935',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '155',meanbuyprice_withDiscount = '155' , productbuypricereal = '155.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='155',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='155',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='155'  WHERE productId = '15812';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32550;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 15812;
UPDATE storedetail SET  productquantity = '1', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15811';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15812', '1', '15', '0', '14069', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-14', '1', '77', '2024-12-12 17:01:46','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06934', '14069', '5', '15820', '15', '140', '2100', '0', '', '2024-12-12 17:05:23', '15820','','','0','0','0','0','0',null,'140','2100','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-12 17:01:46', 1, 15820, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:05:23')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:05:23' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15820', '140', '15', '0', 'buyBillController.php', '32551', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 15820 ;
UPDATE buybilldetail SET  quantitybefore = -5 WHERE buybilldetailid = 32551 ;
UPDATE product SET productName = '6934', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-11-01', conditions = '0', userId = '77', limitamount = '1', parcode = '06934',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '140',meanbuyprice_withDiscount = '140' , productbuypricereal = '145.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='141.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='140',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='140'  WHERE productId = '15820';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32551;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 15820;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15819';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15820', '1', '15', '0', '14069', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-5', '10', '77', '2024-12-12 17:01:46','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 ('06901', '14069', '5', '15736', '10', '360', '3600', '0', '', '2024-12-12 17:05:23', '15736','','','0','0','0','0','0',null,'360','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-12 17:01:46', 1, 15736, 0, 0
                    , 360, 10, 0, 0, 77, '2024-12-12 17:05:24')
                ON DUPLICATE KEY UPDATE buyprice = 360,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:05:24' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15736', '360', '10', '0', 'buyBillController.php', '32552', '', '0', '0');
UPDATE product SET  productBuyPrice = "360" WHERE productId = 15736 ;
UPDATE buybilldetail SET  quantitybefore = -3 WHERE buybilldetailid = 32552 ;
UPDATE product SET productName = '6901', productDescription = '', productCatId = '5', productBuyPrice = '360.00', productSellAllPrice = '410.00', productSellUnitPrice = '410.00', productSellHalfPrice = '410.00', productDate = '2024-10-29', conditions = '0', userId = '77', limitamount = '1', parcode = '06901',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '360',lastbuyprice_withDiscount = '360',meanbuyprice = '360',meanbuyprice_withDiscount = '360' , productbuypricereal = '250.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='360',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='360',meanbuyprice_withTax='360',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='360'  WHERE productId = '15736';
UPDATE buybilldetail SET  lastbuyprice = 360 , meanbuyprice = 360, lastbuyprice_withDiscount = 360, meanbuyprice_withDiscount = 360
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where buybilldetailid = 32552;
UPDATE productunit SET proUnitBuyPrice  = 360 * productnumber WHERE productid = 15736;
UPDATE storedetail SET  productquantity = '7', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15735';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15736', '1', '10', '0', '14069', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-3', '7', '77', '2024-12-12 17:01:46','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 ('R3252', '14069', '1', '15632', '15', '165', '2475', '0', '', '2024-12-12 17:05:23', '15632','','','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-12 17:01:46', 1, 15632, 0, 0
                    , 165, 15, 0, 0, 77, '2024-12-12 17:05:24')
                ON DUPLICATE KEY UPDATE buyprice = 165,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:05:24' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15632', '165', '15', '0', 'buyBillController.php', '32553', '', '0', '0');
UPDATE product SET  productBuyPrice = "165" WHERE productId = 15632 ;
UPDATE buybilldetail SET  quantitybefore = -8 WHERE buybilldetailid = 32553 ;
UPDATE product SET productName = 'R3252', productDescription = '', productCatId = '1', productBuyPrice = '165.00', productSellAllPrice = '210.00', productSellUnitPrice = '210.00', productSellHalfPrice = '210.00', productDate = '2024-10-23', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3252',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 = '15632';
UPDATE buybilldetail SET  lastbuyprice = 165 , meanbuyprice = 165, lastbuyprice_withDiscount = 165, meanbuyprice_withDiscount = 165
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 165, lastbuyprice_withDiscountAndTax = 165
                where buybilldetailid = 32553;
UPDATE productunit SET proUnitBuyPrice  = 165 * productnumber WHERE productid = 15632;
UPDATE storedetail SET  productquantity = '7', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15631';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15632', '1', '15', '0', '14069', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-8', '7', '77', '2024-12-12 17:01:46','0','0');
UPDATE supplier SET  suppliercurrentDebt = '227410',suppliercurrentDebtInCurrency= '227410' , userid = '77', supplierdate = '2024-12-12 17:05:23'   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', '198810.00', '28600', '0', 'اضافة فاتورة مشتريات', '14069', '227410', '2024-12-12 17:01:46', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','28600','1','198810','28600','227410','0');
update buybill set dailyentryid='0,' where buybillid=14069;
COMMIT;
UPDATE product SET overAllAveragePrice = 150.83 WHERE productId = 15389;UPDATE product SET overAllAveragePrice = 165 WHERE productId = 15632;UPDATE product SET overAllAveragePrice = 360 WHERE productId = 15736;UPDATE product SET overAllAveragePrice = 182.5 WHERE productId = 15742;UPDATE product SET overAllAveragePrice = 155 WHERE productId = 15812;UPDATE product SET overAllAveragePrice = 141.11 WHERE productId = 15820;UPDATE product SET overAllAveragePrice = 141.25 WHERE productId = 15821;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 15856;UPDATE product SET overAllAveragePrice = 215 WHERE productId = 15887;UPDATE product SET overAllAveragePrice = 155 WHERE productId = 15924;UPDATE product SET overAllAveragePrice = 165 WHERE productId = 15934;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:35:24";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:05:24", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:05:24', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14069');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:35:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:05:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:05: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 0675afb9018116
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10638,@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-12 17:04:48', '0675afb9018116', '10638', '0.00', '414', '0', '1', '414.00', '414', '0', '414', '1', '2024-12-12 17:05:31', '', '104', '0', 'ام حفصة 52', '1', '1', '3', '97', 'ام حفصة 52', '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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '414', userid = '104' WHERE clientid = '10638';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10638','0.00','414','0','اضافة فاتورة مبيعات','149181', '414', '2024-12-12 17:05:31', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '414', '0', null, '0', null, null,'', '0','1','1','414','1','2024-12-12 17:04:48','0','0');
UPDATE client SET  inUse = 0 where clientid = 10638;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35845;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1617', '149181', '14', '16253', '1', '410', '410', '0', '', '1', '2024-12-12 17:05:31', '16253', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35845-1,','1','1','0','0','410','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 304.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 304.00
        , lastbuyprice_withTax = 300, meanbuyprice_withTax = 302, lastbuyprice_withDiscountAndTax = 300
                where sellbilldetailid = 545129;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16253, '2024-12-12', 410, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+302
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 410, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+302
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 17:05:31' WHERE storedetailid = '16252';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16253', '1', '1', '1', '149181', 'اضافة فاتورة مبيعات', 'sellbillController.php', '40', '39', '104', '2024-12-12 17:05:31','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149181', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-12 17:05:32', '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 = 97 where clientid = 10638;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 414, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+414, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+302
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10638, '2024-12-12', 414, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+414, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+302
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 300, 300
                    , 304, 300, 304, 301.5, 300, 302)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+414, netSellCostBuyPrice = netSellCostBuyPrice+300
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+300
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+304
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+300
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+304
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+301.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+300
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+302;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675afb9018116 and sellbillId = 149181 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:35:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:05:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:05: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-12 13:35:39";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 17:05:39", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:05:39', '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-12 13:36:08";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 17:06:08", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:06:08', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149179');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:36:22";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 17:06:22", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:06:22', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149169');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:37:26";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:07:26", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:07:26', '77', 'bill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:38:09";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:08:09", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:08:09', '77', 'add', '192.168.1.73', '', '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 ('0675afc2f0812c', '2024-12-12 17:07:27', '102', '227410.00', '233335', '0', '0', '5925',  '5925', '0', '5925', '1', '2024-12-12 17:08:09', '', '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 ('H1362', '14070', '14', '15502', '15', '395', '5925', '0', '', '2024-12-12 17:08:09', '15502','','','0','0','0','0','0',null,'395','5925','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-12 17:07:27', 1, 15502, 0, 0
                    , 395, 15, 0, 0, 77, '2024-12-12 17:08:09')
                ON DUPLICATE KEY UPDATE buyprice = 395,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:08:09' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15502', '395', '15', '0', 'buyBillController.php', '32554', '', '0', '0');
UPDATE product SET  productBuyPrice = "395" WHERE productId = 15502 ;
UPDATE buybilldetail SET  quantitybefore = -9 WHERE buybilldetailid = 32554 ;
UPDATE product SET productName = 'H1362', productDescription = '', productCatId = '14', productBuyPrice = '395.00', productSellAllPrice = '470.00', productSellUnitPrice = '470.00', productSellHalfPrice = '470.00', productDate = '2024-10-16', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1362',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '395',lastbuyprice_withDiscount = '395',meanbuyprice = '395',meanbuyprice_withDiscount = '395' , productbuypricereal = '395.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='395',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='395',meanbuyprice_withTax='988',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='395'  WHERE productId = '15502';
UPDATE buybilldetail SET  lastbuyprice = 395 , meanbuyprice = 395, lastbuyprice_withDiscount = 395, meanbuyprice_withDiscount = 395
        , lastbuyprice_withTax = 395, meanbuyprice_withTax = 988, lastbuyprice_withDiscountAndTax = 395
                where buybilldetailid = 32554;
UPDATE productunit SET proUnitBuyPrice  = 395 * productnumber WHERE productid = 15502;
UPDATE storedetail SET  productquantity = '6', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15501';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15502', '1', '15', '0', '14070', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-9', '6', '77', '2024-12-12 17:07:27','0','0');
UPDATE supplier SET  suppliercurrentDebt = '233335',suppliercurrentDebtInCurrency= '233335' , userid = '77', supplierdate = '2024-12-12 17:08:09'   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', '227410.00', '5925', '0', 'اضافة فاتورة مشتريات', '14070', '233335', '2024-12-12 17:07:27', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','5925','1','227410','5925','233335','0');
update buybill set dailyentryid='0,' where buybillid=14070;
COMMIT;
UPDATE product SET overAllAveragePrice = 395 WHERE productId = 15502;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:38:10";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:08:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:08:10', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14070');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:38:28";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:08:28", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:08:28', '77', 'bill', '192.168.1.73', '', '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 ('H1656','','14','365','440', '440','440', '2024-12-12', '0', '77', '1', 'H1656', '0', '0', '0', '0', '0', '365','365','365','365','365','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','365','365','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16413, 1,'2024-12-12 17:08:57',77)
                ON DUPLICATE KEY UPDATE productid = 16413, edited = 1, sysdate = '2024-12-12 17:08: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', '16413', '1', '2024-12-12', '77', '0','1641301','440','440','440','365','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16413', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16413', '1', '0', '0', '16413', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:39:38";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:09:38", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:09:38', '77', 'add', '192.168.1.73', '', '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 ('0675afc6c6e158', '2024-12-12 17:08:28', '102', '233335.00', '238810', '0', '0', '5475',  '5475', '0', '5475', '1', '2024-12-12 17:09:38', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1656', '14071', '14', '16413', '15', '365', '5475', '0', '', '2024-12-12 17:09:38', '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-12 17:08:28', 1, 16413, 0, 0
                    , 365, 15, 0, 0, 77, '2024-12-12 17:09:38')
                ON DUPLICATE KEY UPDATE buyprice = 365,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:09:38' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16413', '365', '15', '0', 'buyBillController.php', '32555', '', '0', '0');
UPDATE product SET  productBuyPrice = "365" WHERE productId = 16413 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32555 ;
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='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='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 = 32555;
UPDATE productunit SET proUnitBuyPrice  = 365 * productnumber WHERE productid = 16413;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16412';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16413', '1', '15', '0', '14071', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-12 17:08:28','0','0');
UPDATE supplier SET  suppliercurrentDebt = '238810',suppliercurrentDebtInCurrency= '238810' , userid = '77', supplierdate = '2024-12-12 17:09:38'   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', '233335.00', '5475', '0', 'اضافة فاتورة مشتريات', '14071', '238810', '2024-12-12 17:08:28', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','5475','1','233335','5475','238810','0');
update buybill set dailyentryid='0,' where buybillid=14071;
COMMIT;
UPDATE product SET overAllAveragePrice = 365 WHERE productId = 16413;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:39:39";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:09:39", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:09:39', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14071');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:39:54";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:09:54", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:09:54', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245876
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10638,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12 17:09:54', userid = '2' WHERE clientid = '10638';
UPDATE client SET  inUse = 0 where clientid = 10638;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10638','414.00','414','1','ايصال تحصيل (( قبض من عميل ))','245876', '0', '2024-12-12 17:04:07', '2', 'clientPayedDeptController.php', '   ', '414', '0', null, '0', null, null,'', '-1','1','1','414','1','','3161','0');
UPDATE save SET  savecurrentvalue = '494876.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('494462.50','414', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245879', '494876.5', '2024-12-12 17: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 ( '414', '414', '2024-12-12', '2', '0', '0', '2024-12-12 17:09:54','اضافة ايصال سداد للعميل ام حفصة 52','1','0','0','0','245879','clientPayedDeptController.php?do=show&id=245879');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121744', '-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 ('121744', '12312', '414', '','0');
UPDATE accountstree SET name = 'ام حفصة 52', customName = 'ام حفصة 52', customNameEn = 'ام حفصة 52', nameEn = 'ام حفصة 52', parent = '58', accountNature = '0', theValue = '-1192', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '9', del = '0', sysdate = '2024-12-07 19:18:15' WHERE id = '12312';
UPDATE clientdebtchange SET clientid = '10638', clientdebtchangebefore = '414.000', clientdebtchangeamount = '414.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245876', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-12 17:04:07', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '414.00',discount='', reciptid='0', dailyentryid = '121744',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='414',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245879';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245876 -clientdebtchangeId = 245879
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:39:55";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:09:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:09:55', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:41:00";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:11:00", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-12 17:11:00', '77', 'showbarcodebuybill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14071&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:41:08";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:11:08", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-12 17:11:08', '77', 'showbarcodebuybill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14071&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:42:18";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:12:18", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-12 17:12:18', '77', 'oneSupplier', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:42:24";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:12:24", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-12 17:12:24', '77', 'oneSupplier', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE userid = 101;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:42:55";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:12:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 17:12:55', '2', '', '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-12 13:42:56";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:42:57";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:12:57", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 17:12:57', '2', '', '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-12 13:42:57";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:43:00";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:13:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 17:13:00', '2', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:43:26";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:13:26", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 17:13:26', '2', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:44:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:14:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierPayedDeptController.php', '2024-12-12 17:14:05', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:44:19";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 17:14:19", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:14:19', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675afb98421fb
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5449,@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-12 17:04:56', '0675afb98421fb', '5449', '-2.00', '816', '0', '1', '818.00', '818', '0', '818', '1', '2024-12-12 17:14:20', '', '75', '0', 'ام رقية t80', '2', '1', '3', '89', 'ام رقية t80', '7' ,'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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '816', userid = '75' WHERE clientid = '5449';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5449','-2.00','818','0','اضافة فاتورة مبيعات','149182', '816', '2024-12-12 17:14:20', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '818', '0', null, '0', null, null,'', '0','1','1','818','1','2024-12-12 17:04:56','0','0');
UPDATE client SET  inUse = 0 where clientid = 5449;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32482;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06418', '149182', '5', '14618', '1', '130', '130', '0', '', '1', '2024-12-12 17:14:20', '14618', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32482-1,','1','1','0','0','130','130','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 = 545131;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14618, '2024-12-12', 130, 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+130, 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-12', 130, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, 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 = '75', storedetaildate = '2024-12-12 17:14:20' WHERE storedetailid = '14617';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14618', '1', '1', '1', '149182', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-12 17:14: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 ('250','R2647', '149182', '1', '12978', '1', '110', '110', '0', '', '1', '2024-12-12 17:14:20', '12978', '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 = 250.00 , meanbuyprice = 255.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 255.00
        
                where sellbilldetailid = 545132;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12978, '2024-12-12', 110, 250, 250
                    , 255, 250, 255, 255.71
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+110, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+255.71
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 110, 250, 250
                    , 255, 250, 255, 255.71
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+110, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+255.71
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 17:14:20' WHERE storedetailid = '12977';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12978', '1', '1', '1', '149182', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-12 17:14:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34139;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('100','06794', '149182', '5', '15413', '1', '155', '155', '0', '', '1', '2024-12-12 17:14:20', '15413', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34139-1,','1','1','0','0','155','155','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 100.00 , meanbuyprice = 100.00, lastbuyprice_withDiscount = 100.00, meanbuyprice_withDiscount = 100.00
        
                where sellbilldetailid = 545133;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15413, '2024-12-12', 155, 100, 100
                    , 100, 100, 100, 100
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+100
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+100
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+100
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 155, 100, 100
                    , 100, 100, 100, 100
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+100
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+100
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+100
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 17:14:20' WHERE storedetailid = '15412';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15413', '1', '1', '1', '149182', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-12 17:14:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34535;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06813', '149182', '5', '15496', '1', '120', '120', '0', '', '1', '2024-12-12 17:14:20', '15496', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34535-1,','1','1','0','0','120','120','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 = 61, lastbuyprice_withDiscountAndTax = 150
                where sellbilldetailid = 545134;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15496, '2024-12-12', 120, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 150, 61, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+61
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 120, 150, 150
                    , 150, 150, 150, 150
                    , 0, 0, 0, 0
                    , 0, 0, 0, 150, 61, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+150
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+150, sellCostMeanBuyPrice = sellCostMeanBuyPrice+150
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+150, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+150
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+150
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+150
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+61
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 17:14:20' WHERE storedetailid = '15495';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15496', '1', '1', '1', '149182', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-12 17:14:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35397;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('215','0K789', '149182', '7', '15760', '1', '275', '275', '0', '', '1', '2024-12-12 17:14:20', '15760', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35397-1,','1','1','0','0','275','275','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 215.00 , meanbuyprice = 215.00, lastbuyprice_withDiscount = 215.00, meanbuyprice_withDiscount = 215.00
        , lastbuyprice_withTax = 215, meanbuyprice_withTax = 215, lastbuyprice_withDiscountAndTax = 215
                where sellbilldetailid = 545135;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15760, '2024-12-12', 275, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 215, 215, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+215
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 275, 215, 215
                    , 215, 215, 215, 215
                    , 0, 0, 0, 0
                    , 0, 0, 0, 215, 215, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+275, sellCostBuyPrice =sellCostBuyPrice+215
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+215, sellCostMeanBuyPrice = sellCostMeanBuyPrice+215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+215, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+215
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+215
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+215
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+215
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '28', userid = '75', storedetaildate = '2024-12-12 17:14:20' WHERE storedetailid = '15759';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15760', '1', '1', '1', '149182', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29', '28', '75', '2024-12-12 17:14: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', '149182', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 17:14: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', '149182', '17', '10291', '1', '8', '8', '0', '', '1', '2024-12-12 17:14: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 = 89 where clientid = 5449;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 818, 865, 865
                    , 870, 865, 870, 870.71
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,365, 276, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+818, sellCostBuyPrice =sellCostBuyPrice+865
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+865, sellCostMeanBuyPrice = sellCostMeanBuyPrice+870
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+865, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+870
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+870.71
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+365
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+276
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (5449, '2024-12-12', 818, 865, 865
                    , 870, 865, 870, 870.71
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,365, 276, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+818, sellCostBuyPrice =sellCostBuyPrice+865
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+865, sellCostMeanBuyPrice = sellCostMeanBuyPrice+870
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+865, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+870
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+870.71
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+365
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+276
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 865, 865
                    , 870, 865, 870, 870.71, 365, 276)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+818, netSellCostBuyPrice = netSellCostBuyPrice+865
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+865
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+870
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+865
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+870
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+870.71
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+365
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+276;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675afb98421fb and sellbillId = 149182 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:44:21";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 17:14:21", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:14: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 userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:44:52";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:14:52", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:14:52', '77', 'bill', '192.168.1.73', '', '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 ('H1655','','14','710','825', '825','825', '2024-12-12', '0', '77', '1', 'H1655', '0', '0', '0', '0', '0', '710','710','710','710','710','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','710','710','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16414, 1,'2024-12-12 17:15:28',77)
                ON DUPLICATE KEY UPDATE productid = 16414, edited = 1, sysdate = '2024-12-12 17:15:28', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16414', '1', '2024-12-12', '77', '0','1641401','825','825','825','710','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16414', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16414', '1', '0', '0', '16414', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:45:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:15:34", deviceType = "DESKTOP" WHERE userid = 104;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:45:34";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:15:34", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:15:34', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:15:34', '77', 'add', '192.168.1.73', '', '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 ('0675afded1803c', '2024-12-12 17:14:53', '20', '327260.00', '337910', '0', '0', '10650',  '10650', '0', '10650', '1', '2024-12-12 17:15:34', '', '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 ('H1655', '14072', '14', '16414', '15', '710', '10650', '0', '', '2024-12-12 17:15:34', '16414','','','0','0','0','0','0',null,'710','10650','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-12 17:14:53', 1, 16414, 0, 0
                    , 710, 15, 0, 0, 77, '2024-12-12 17:15:34')
                ON DUPLICATE KEY UPDATE buyprice = 710,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:15:34' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16414', '710', '15', '0', 'buyBillController.php', '32556', '', '0', '0');
UPDATE product SET  productBuyPrice = "710" WHERE productId = 16414 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32556 ;
UPDATE product SET productName = 'H1655', productDescription = '', productCatId = '14', productBuyPrice = '710.00', productSellAllPrice = '825.00', productSellUnitPrice = '825.00', productSellHalfPrice = '825.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1655',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '710',lastbuyprice_withDiscount = '710',meanbuyprice = '710',meanbuyprice_withDiscount = '710' , productbuypricereal = '710.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='710',meanbuyprice_withTax='710',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='710'  WHERE productId = '16414';
UPDATE buybilldetail SET  lastbuyprice = 710 , meanbuyprice = 710, lastbuyprice_withDiscount = 710, meanbuyprice_withDiscount = 710
        , lastbuyprice_withTax = 710, meanbuyprice_withTax = 710, lastbuyprice_withDiscountAndTax = 710
                where buybilldetailid = 32556;
UPDATE productunit SET proUnitBuyPrice  = 710 * productnumber WHERE productid = 16414;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16413';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16414', '1', '15', '0', '14072', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-12 17:14:53','0','0');
UPDATE supplier SET  suppliercurrentDebt = '337910',suppliercurrentDebtInCurrency= '337910' , userid = '77', supplierdate = '2024-12-12 17:15:34'   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', '327260.00', '10650', '0', 'اضافة فاتورة مشتريات', '14072', '337910', '2024-12-12 17:14:53', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','10650','1','327260','10650','337910','0');
update buybill set dailyentryid='0,' where buybillid=14072;
COMMIT;
UPDATE product SET overAllAveragePrice = 710 WHERE productId = 16414;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:45:35";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:15:35", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:15:35', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14072');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:45:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:15:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:15:40', '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', '10000', '2024-12-12', '104', '0', '0','','1','1','0','0','10000');
UPDATE save SET  savecurrentvalue = '15310',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('25310.00','10000', '1', '1', 'تحويل امول الى الخزنة  [ جمعيه ] ', '3489', '15310', '2024-12-12 17:15:40', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '100000',  userid = '104' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('90000.00','10000', '0', '5', 'تحويل امول من الخزنة  [ نقدي ] ', '3489', '100000', '2024-12-12 17:15:40', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '5', transfermoneyvalue = '10000.00', transfermoneydate = '2024-12-12', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='10000' WHERE transfermoneyid = '3489';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:45:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:15:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:15:41', '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-12 13:45:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:15:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:15:42', '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-12 13:45:52";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:15:52", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:15:52', '77', 'bill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
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' , '', '', '01117143857', '0', '', '0', '2024-12-12 17:16:24', '75', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-12','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10683', '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 ('10683','0','0','0','إضافة عميل جديد','10683', '0', '2024-12-12 17:16:24', '75', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('اسماء محمد 33', 'اسماء محمد 33', 'اسماء محمد 33', 'اسماء محمد 33', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '75', '0', '2024-12-12 17:16:24');
UPDATE client SET clientname = 'اسماء محمد 33', clientaddress = '', clientphone = '', clientmobile = '01117143857', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-12', 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='12424',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10683';
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-12 13:47:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:17:49", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 17:17:49', '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-12 13:47:50";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:47:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:17:52", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:17:52', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:47:53";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 17:17:53", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:17: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 0675afdcd2d7bb
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10683,@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-12 17:14:21', '0675afdcd2d7bb', '10683', '0.00', '1061', '0', '1', '1061.00', '1061', '0', '1061', '1', '2024-12-12 17:17:53', '', '75', '0', 'اسماء محمد 33', '2', '1', '3', '89', 'اسماء محمد 33', '6' ,'0','','','','','-1','0','0','0','0','0','1061','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1061', userid = '75' WHERE clientid = '10683';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10683','0.00','1061','0','اضافة فاتورة مبيعات','149183', '1061', '2024-12-12 17:17:53', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1061', '0', null, '0', null, null,'', '0','1','1','1061','1','2024-12-12 17:14:21','0','0');
UPDATE client SET  inUse = 0 where clientid = 10683;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35714;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07155', '149183', '5', '16212', '1', '330', '330', '0', '', '1', '2024-12-12 17:17:53', '16212', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35714-1,','1','1','0','0','330','330','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 = 545138;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16212, '2024-12-12', 330, 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+330, 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-12', 330, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 280, 280, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, 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 = '6', userid = '75', storedetaildate = '2024-12-12 17:17:53' WHERE storedetailid = '16211';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16212', '1', '1', '1', '149183', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7', '6', '75', '2024-12-12 17:17:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35626;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149183', '5', '16170', '1', '300', '300', '0', '', '1', '2024-12-12 17:17:53', '16170', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35626-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 = 545139;
 INSERT INTO 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-12', 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-12', 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 = '16', userid = '75', storedetaildate = '2024-12-12 17:17:53' WHERE storedetailid = '16169';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16170', '1', '1', '1', '149183', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '75', '2024-12-12 17:17:53','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34533;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06869', '149183', '5', '15646', '1', '200', '200', '0', '', '1', '2024-12-12 17:17:53', '15646', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34533-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 = 545140;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15646, '2024-12-12', 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-12', 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 = '0', userid = '75', storedetaildate = '2024-12-12 17:17:53' WHERE storedetailid = '15645';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15646', '1', '1', '1', '149183', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-12 17:17:53','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', '149183', '5', '15820', '1', '200', '200', '0', '', '1', '2024-12-12 17:17:53', '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 = 545141;
 INSERT INTO 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-12', 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-12', 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 = '9', userid = '75', storedetaildate = '2024-12-12 17:17:53' WHERE storedetailid = '15819';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15820', '1', '1', '1', '149183', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-12 17:17: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', '149183', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 17:17: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', '149183', '17', '10291', '1', '11', '11', '0', '', '1', '2024-12-12 17:17:53', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','11','11','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 89 where clientid = 10683;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1061, 810, 810
                    , 810, 810, 810, 811.11
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,810, 810, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1061, sellCostBuyPrice =sellCostBuyPrice+810
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+810, sellCostMeanBuyPrice = sellCostMeanBuyPrice+810
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+810, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+810
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+811.11
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+810
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+810
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10683, '2024-12-12', 1061, 810, 810
                    , 810, 810, 810, 811.11
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,810, 810, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1061, sellCostBuyPrice =sellCostBuyPrice+810
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+810, sellCostMeanBuyPrice = sellCostMeanBuyPrice+810
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+810, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+810
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+811.11
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+810
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+810
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1061, 810, 810
                    , 810, 810, 810, 811.11, 810, 810)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1061, netSellCostBuyPrice = netSellCostBuyPrice+810
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+810
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+810
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+810
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+810
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+811.11
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+810
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+810;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675afdcd2d7bb and sellbillId = 149183 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:47:54";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 17:17:54", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:17: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-12 13:48:51";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:18:51", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 17:18:51', '77', '', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:49:05";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:19:05", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 17:19:05', '77', 'show', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:50:03";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:20:03", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:20: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-12 13:50:04";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:20:04", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:20:04', '77', 'show', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
UPDATE user SET loginip = "" WHERE userid = 9;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:50:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:20:24", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 17:20:24', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:50:24";
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 17:20:24", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:20:24', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');
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;

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675af7f57fea7
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7759,@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-12 16:49:25', '0675af7f57fea7', '7759', '0.00', '869', '0', '1', '869.00', '869', '0', '869', '1', '2024-12-12 17:20:24', '', '75', '0', 'دنيا اشرف 33', '2', '1', '3', '89', 'دنيا اشرف 33', '5' ,'0','','','','','-1','0','0','0','0','0','869','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '869', userid = '75' WHERE clientid = '7759';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7759','0.00','869','0','اضافة فاتورة مبيعات','149184', '869', '2024-12-12 17:20:24', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '869', '0', null, '0', null, null,'', '0','1','1','869','1','2024-12-12 16:49:25','0','0');
UPDATE client SET  inUse = 0 where clientid = 7759;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06226', '149184', '5', '14162', '1', '270', '270', '0', '', '1', '2024-12-12 17:20:24', '14162', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','270','270','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
        
                where sellbilldetailid = 545144;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14162, '2024-12-12', 270, 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+270, 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-12', 270, 280, 280
                    , 280, 280, 280, 280
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+270, sellCostBuyPrice =sellCostBuyPrice+280
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+280
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+280
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+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 = '0', userid = '75', storedetaildate = '2024-12-12 17:20:24' WHERE storedetailid = '14161';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14162', '1', '1', '1', '149184', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-12 17:20:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 31191;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06129', '149184', '5', '13870', '2', '285', '570', '0', '', '1', '2024-12-12 17:20:24', '13870', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31191-2,','1','1','0','0','285','570','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 345.00 , meanbuyprice = 345.00, lastbuyprice_withDiscount = 345.00, meanbuyprice_withDiscount = 345.00
        
                where sellbilldetailid = 545145;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13870, '2024-12-12', 570, 690, 690
                    , 690, 690, 690, 690
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+570, sellCostBuyPrice =sellCostBuyPrice+690
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+690, sellCostMeanBuyPrice = sellCostMeanBuyPrice+690
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+690, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+690
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+690
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+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-12', 570, 690, 690
                    , 690, 690, 690, 690
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+570, sellCostBuyPrice =sellCostBuyPrice+690
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+690, sellCostMeanBuyPrice = sellCostMeanBuyPrice+690
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+690, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+690
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+690
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 17:20:24' WHERE storedetailid = '13869';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13870', '1', '2', '1', '149184', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '4', '75', '2024-12-12 17:20: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', '149184', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 17:20: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', '149184', '17', '10291', '1', '9', '9', '0', '', '1', '2024-12-12 17:20:24', '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 = 7759;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 869, 970, 970
                    , 970, 970, 970, 970
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+869, sellCostBuyPrice =sellCostBuyPrice+970
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+970, sellCostMeanBuyPrice = sellCostMeanBuyPrice+970
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+970, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+970
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+970
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7759, '2024-12-12', 869, 970, 970
                    , 970, 970, 970, 970
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+869, sellCostBuyPrice =sellCostBuyPrice+970
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+970, sellCostMeanBuyPrice = sellCostMeanBuyPrice+970
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+970, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+970
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+970
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 869, 970, 970
                    , 970, 970, 970, 970, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+869, netSellCostBuyPrice = netSellCostBuyPrice+970
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+970
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+970
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+970
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+970
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+970
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675af7f57fea7 and sellbillId = 149184 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:50:24";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:50:25";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 17:20:25", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:20: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-12 13:50:27";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:20:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:20:27', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:50:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:20:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 17:20:28', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:50:42";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:20:42", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:20:42', '77', 'edit', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=edit&transfermoneyid=3489');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:50:50";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:20:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:20:50', '77', 'update', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=update');
BEGIN;
UPDATE transfermoney SET saveidfrom = '1', saveidto = '5', transfermoneyvalue = '10000.00', transfermoneydate = '2024-12-12', userid = '104', conditions = '2' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='10000' WHERE transfermoneyid = '3489';
UPDATE save SET  savecurrentvalue = '90000',  userid = '77' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('100000.00','10000', '1', '5', 'الغاء تحويل امول من الخزنة  [ نقدي ] ', '3489', '90000', '2024-12-12 17:20:50', '77',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '25310',  userid = '77' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('15310.00','10000', '0', '1', 'الغاء تحويل امول الى الخزنة  [ جمعيه ] ', '3489', '25310', '2024-12-12 17:20:50', '77',  'transfermoneyController.php','0','','0');
COMMIT;
BEGIN;
INSERT INTO transfermoney (saveidfrom, saveidto, transfermoneyvalue, transfermoneydate, userid, conditions, dailyentryid , comment,currencyId,conversionFactor,conversionFactorFrom,conversionFactorTo,transfermoneyvalueInCurrency) VALUES ('1','15', '10000', '2024-12-12', '77', '0', '0','','1','1','0','0','10000');
UPDATE save SET  savecurrentvalue = '15310',  userid = '77' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('25310.00','10000', '1', '1', 'تحويل امول الى الخزنة  [ جمعيه الشيخ ] ', '3490', '15310', '2024-12-12 17:20:50', '77',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '220000',  userid = '77' WHERE saveid = '15';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('210000.00','10000', '0', '15', 'تحويل امول من الخزنة  [ نقدي ] ', '3490', '220000', '2024-12-12 17:20:50', '77',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '15', transfermoneyvalue = '10000.00', transfermoneydate = '2024-12-12', userid = '77', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='10000' WHERE transfermoneyid = '3490';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:50:50";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:20:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:20:50', '77', 'sucess', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:50:52";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:20:52", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:20:52', '77', 'show', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php?do=show');
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId,runquery,weightedDiscount,sortby,obygyInvestigationId,TypeOfBarcodeInTax,barcodeInTax,productNameE,partNumber,vehicleType,company,weight,origin,hscode,power,ProductionDate,expiry,procode,lastbuyprice_withTax,meanbuyprice_withTax,price4,price5,price6,price7,price8,clientid,grantduration,onlinepro,minappearonline,selladdpercent,selldiscountpercent,buydiscountpercent,onlinecatid,sellpercenttype,searchfiltersid,lastbuyprice_withDiscountAndTax) VALUES ('7284','','5','140','200', '200','200', '2024-12-12', '0', '77', '1', '07284', '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 (16415, 1,'2024-12-12 17:21:12',77)
                ON DUPLICATE KEY UPDATE productid = 16415, edited = 1, sysdate = '2024-12-12 17:21:12', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16415', '1', '2024-12-12', '77', '0','1641501','200','200','200','140','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16415', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16415', '1', '0', '0', '16415', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:51:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:21:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 17:21:23', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:51:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:21:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:21:36', '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-12 13:51:37";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:21:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:21:37', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245880
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245880 -clientdebtchangeId = 245884
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:51:38";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:21:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:21:38', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:51:59";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:21:59", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-12 17:21:59', '77', 'oneSupplier', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:52:10";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 17:22:10", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:22: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 0675afea27954b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10293,@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-12 17:17:54', '0675afea27954b', '10293', '6.00', '683', '0', '1', '677.00', '677', '0', '677', '1', '2024-12-12 17:22:10', '', '75', '0', 'رنا ديروط ', '2', '1', '3', '85', 'رنا ديروط ', '4' ,'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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '683', userid = '75' WHERE clientid = '10293';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10293','6.00','677','0','اضافة فاتورة مبيعات','149185', '683', '2024-12-12 17:22:10', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '677', '0', null, '0', null, null,'', '0','1','1','677','1','2024-12-12 17:17:54','0','0');
UPDATE client SET  inUse = 0 where clientid = 10293;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36104;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06603', '149185', '5', '15038', '1', '290', '290', '0', '', '1', '2024-12-12 17:22:10', '15038', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36104-1,','1','1','0','0','290','290','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 = 234, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 545148;
 INSERT INTO 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-12', 290, 240, 240
                    , 235, 240, 235, 239.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 240, 234, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+234
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 290, 240, 240
                    , 235, 240, 235, 239.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 234, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+239.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+234
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 17:22:10' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '1', '1', '149185', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-8', '-9', '75', '2024-12-12 17:22:10','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', '149185', '5', '15674', '1', '360', '360', '0', '', '1', '2024-12-12 17:22:10', '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 = 545149;
 INSERT INTO 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-12', 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-12', 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 = '53', userid = '75', storedetaildate = '2024-12-12 17:22:10' WHERE storedetailid = '15673';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15674', '1', '1', '1', '149185', 'اضافة فاتورة مبيعات', 'sellbillController.php', '54', '53', '75', '2024-12-12 17:22: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', '149185', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 17:22: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', '149185', '17', '10291', '1', '7', '7', '0', '', '1', '2024-12-12 17:22:10', '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 = 10293;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 677, 535, 535
                    , 530, 535, 530, 534.33
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,535, 529, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+677, sellCostBuyPrice =sellCostBuyPrice+535
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+535, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+534.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+535
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+529
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10293, '2024-12-12', 677, 535, 535
                    , 530, 535, 530, 534.33
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,535, 529, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+677, sellCostBuyPrice =sellCostBuyPrice+535
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+535, sellCostMeanBuyPrice = sellCostMeanBuyPrice+530
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+530
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+534.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+535
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+529
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 535, 535
                    , 530, 535, 530, 534.33, 535, 529)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+677, netSellCostBuyPrice = netSellCostBuyPrice+535
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+535
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+530
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+535
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+530
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+534.33
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+535
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+529;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675afea27954b and sellbillId = 149185 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:52:11";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 17:22:11", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:22: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-12 13:52:12";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:22:12", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-12 17:22:12', '77', 'oneSupplier', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:53:14";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:23:14", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:23:14', '77', 'add', '192.168.1.73', '', '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 ('0675afe2930fda', '2024-12-12 17:15:53', '19', '287955.00', '300780', '0', '0', '12825',  '12825', '0', '12825', '1', '2024-12-12 17:23: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 ('07226', '14073', '5', '16294', '15', '155', '2325', '0', '', '2024-12-12 17:23:14', '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-12 17:15:53', 1, 16294, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-12 17:23:14')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:23:14' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16294', '155', '15', '0', 'buyBillController.php', '32557', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 16294 ;
UPDATE buybilldetail SET  quantitybefore = 46 WHERE buybilldetailid = 32557 ;
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 = '155',meanbuyprice_withDiscount = '155' , productbuypricereal = '155.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='155',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='155',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='155'  WHERE productId = '16294';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32557;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 16294;
UPDATE storedetail SET  productquantity = '61', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '15', '0', '14073', 'اضافة فاتورة مشتريات', 'buyBillController.php', '46', '61', '77', '2024-12-12 17:15: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 ('07001', '14073', '5', '15970', '15', '140', '2100', '0', '', '2024-12-12 17:23:14', '15970','','','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-12 17:15:53', 1, 15970, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:23:14')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:23:14' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15970', '140', '15', '0', 'buyBillController.php', '32558', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 15970 ;
UPDATE buybilldetail SET  quantitybefore = 8 WHERE buybilldetailid = 32558 ;
UPDATE product SET productName = '7001', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-11-15', conditions = '0', userId = '77', limitamount = '1', parcode = '07001',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.56',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='144',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 = '15970';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 144, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32558;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 15970;
UPDATE storedetail SET  productquantity = '23', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15969';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15970', '1', '15', '0', '14073', 'اضافة فاتورة مشتريات', 'buyBillController.php', '8', '23', '77', '2024-12-12 17:15: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 ('07228', '14073', '5', '16348', '15', '140', '2100', '0', '', '2024-12-12 17:23:14', '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-12 17:15:53', 1, 16348, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:23:14')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:23:14' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16348', '140', '15', '0', 'buyBillController.php', '32559', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16348 ;
UPDATE buybilldetail SET  quantitybefore = 8 WHERE buybilldetailid = 32559 ;
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 = 32559;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16348;
UPDATE storedetail SET  productquantity = '23', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16347';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16348', '1', '15', '0', '14073', 'اضافة فاتورة مشتريات', 'buyBillController.php', '8', '23', '77', '2024-12-12 17:15: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 ('07284', '14073', '5', '16415', '15', '140', '2100', '0', '', '2024-12-12 17:23:14', '16415','','','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-12 17:15:53', 1, 16415, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:23:14')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:23:14' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16415', '140', '15', '0', 'buyBillController.php', '32560', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16415 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32560 ;
UPDATE product SET productName = '7284', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07284',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 = '16415';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32560;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16415;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16414';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16415', '1', '15', '0', '14073', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-12 17:15: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 ('07206', '14073', '5', '16300', '15', '140', '2100', '0', '', '2024-12-12 17:23:14', '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-12 17:15:53', 1, 16300, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:23:14')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:23:14' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16300', '140', '15', '0', 'buyBillController.php', '32561', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16300 ;
UPDATE buybilldetail SET  quantitybefore = 11 WHERE buybilldetailid = 32561 ;
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 = 32561;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16300;
UPDATE storedetail SET  productquantity = '26', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16299';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16300', '1', '15', '0', '14073', 'اضافة فاتورة مشتريات', 'buyBillController.php', '11', '26', '77', '2024-12-12 17:15: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 ('07199', '14073', '5', '16299', '15', '140', '2100', '0', '', '2024-12-12 17:23:14', '16299','','','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-12 17:15:53', 1, 16299, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:23:14')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:23:14' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16299', '140', '15', '0', 'buyBillController.php', '32562', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16299 ;
UPDATE buybilldetail SET  quantitybefore = 6 WHERE buybilldetailid = 32562 ;
UPDATE product SET productName = '7199', 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 = '07199',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 = '16299';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32562;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16299;
UPDATE storedetail SET  productquantity = '21', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16298';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16299', '1', '15', '0', '14073', 'اضافة فاتورة مشتريات', 'buyBillController.php', '6', '21', '77', '2024-12-12 17:15:53','0','0');
UPDATE supplier SET  suppliercurrentDebt = '297035',suppliercurrentDebtInCurrency= '300780' , userid = '77', supplierdate = '2024-12-12 17:23:14'   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', '284210.00', '12825', '0', 'اضافة فاتورة مشتريات', '14073', '297035', '2024-12-12 17:15:53', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','12825','1','287955','12825','300780','0');
update buybill set dailyentryid='0,' where buybillid=14073;
COMMIT;
UPDATE product SET overAllAveragePrice = 140.5 WHERE productId = 15970;UPDATE product SET overAllAveragePrice = 155 WHERE productId = 16294;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16299;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16300;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16348;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16415;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:53:15";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:23:15", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:23:15', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14073');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:53:20";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:23:20", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-12 17:23:20', '77', 'showbarcodebuybill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14073&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:53:50";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:23:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-12 17:23:50', '77', 'oneSupplier', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:54:31";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:24:31", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:24:31', '77', 'bill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:55:03";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:25:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:25:03', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245885
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(6831,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12 17:25:03', userid = '2' WHERE clientid = '6831';
UPDATE client SET  inUse = 0 where clientid = 6831;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('6831','303.00','303','1','ايصال تحصيل (( قبض من عميل ))','245885', '0', '2024-12-12 17:21:38', '2', 'clientPayedDeptController.php', '   ', '303', '0', null, '0', null, null,'', '-1','1','1','303','1','','3163','0');
UPDATE save SET  savecurrentvalue = '496502.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('496199.50','303', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245886', '496502.5', '2024-12-12 17: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 ( '303', '303', '2024-12-12', '2', '0', '0', '2024-12-12 17:25:03','اضافة ايصال سداد للعميل امل برهوم X51','1','0','0','0','245886','clientPayedDeptController.php?do=show&id=245886');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121746', '-1', '303', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '303', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121746', '-1', '303', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-303', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '6831', clientdebtchangebefore = '303.000', clientdebtchangeamount = '303.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245885', clientdebtchangeafter = '0.000', clientdebtchangedate = '2024-12-12 17:21:38', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '303.00',discount='', reciptid='0', dailyentryid = '121746',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='303',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245886';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245885 -clientdebtchangeId = 245886
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:55:04";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:25:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:25:04', '2', '', '192.168.1.16', '', '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 ('7291','','5','330','400', '400','400', '2024-12-12', '0', '77', '1', '07291', '0', '0', '0', '0', '0', '330','330','330','330','330','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','330','330','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16416, 1,'2024-12-12 17:25:24',77)
                ON DUPLICATE KEY UPDATE productid = 16416, edited = 1, sysdate = '2024-12-12 17:25: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', '16416', '1', '2024-12-12', '77', '0','1641601','400','400','400','330','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16416', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16416', '1', '0', '0', '16416', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:55:25";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:25:25", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:25:25', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245887
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:55:26";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:25:26", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:25:26', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:55:38";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:25:38", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:25:38', '77', 'add', '192.168.1.73', '', '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 ('0675b002f7a675', '2024-12-12 17:24:31', '19', '300780.00', '309730', '0', '0', '8950',  '8950', '0', '8950', '1', '2024-12-12 17:25:38', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('R3319', '14074', '1', '16223', '10', '400', '4000', '0', '', '2024-12-12 17:25:38', '16223','','','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-12 17:24:31', 1, 16223, 0, 0
                    , 400, 10, 0, 0, 77, '2024-12-12 17:25:38')
                ON DUPLICATE KEY UPDATE buyprice = 400,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:25:38' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16223', '400', '10', '0', 'buyBillController.php', '32563', '', '0', '0');
UPDATE product SET  productBuyPrice = "400" WHERE productId = 16223 ;
UPDATE buybilldetail SET  quantitybefore = 8 WHERE buybilldetailid = 32563 ;
UPDATE product SET productName = 'R3319', productDescription = '', productCatId = '1', productBuyPrice = '400.00', productSellAllPrice = '470.00', productSellUnitPrice = '470.00', productSellHalfPrice = '470.00', productDate = '2024-11-30', conditions = '0', userId = '77', limitamount = '1', parcode = 'R3319',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 = '16223';
UPDATE buybilldetail SET  lastbuyprice = 400 , meanbuyprice = 400, lastbuyprice_withDiscount = 400, meanbuyprice_withDiscount = 400
        , lastbuyprice_withTax = 400, meanbuyprice_withTax = 400, lastbuyprice_withDiscountAndTax = 400
                where buybilldetailid = 32563;
UPDATE productunit SET proUnitBuyPrice  = 400 * productnumber WHERE productid = 16223;
UPDATE storedetail SET  productquantity = '18', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16223', '1', '10', '0', '14074', 'اضافة فاتورة مشتريات', 'buyBillController.php', '8', '18', '77', '2024-12-12 17:24:31','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07291', '14074', '5', '16416', '15', '330', '4950', '0', '', '2024-12-12 17:25:38', '16416','','','0','0','0','0','0',null,'330','4950','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-12 17:24:31', 1, 16416, 0, 0
                    , 330, 15, 0, 0, 77, '2024-12-12 17:25:38')
                ON DUPLICATE KEY UPDATE buyprice = 330,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:25:38' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16416', '330', '15', '0', 'buyBillController.php', '32564', '', '0', '0');
UPDATE product SET  productBuyPrice = "330" WHERE productId = 16416 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32564 ;
UPDATE product SET productName = '7291', productDescription = '', productCatId = '5', productBuyPrice = '330.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '400.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07291',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '330',lastbuyprice_withDiscount = '330',meanbuyprice = '330',meanbuyprice_withDiscount = '330' , productbuypricereal = '330.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='330',meanbuyprice_withTax='330',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='330'  WHERE productId = '16416';
UPDATE buybilldetail SET  lastbuyprice = 330 , meanbuyprice = 330, lastbuyprice_withDiscount = 330, meanbuyprice_withDiscount = 330
        , lastbuyprice_withTax = 330, meanbuyprice_withTax = 330, lastbuyprice_withDiscountAndTax = 330
                where buybilldetailid = 32564;
UPDATE productunit SET proUnitBuyPrice  = 330 * productnumber WHERE productid = 16416;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16415';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16416', '1', '15', '0', '14074', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-12 17:24:31','0','0');
UPDATE supplier SET  suppliercurrentDebt = '305985',suppliercurrentDebtInCurrency= '309730' , userid = '77', supplierdate = '2024-12-12 17:25:38'   WHERE supplierid = '19';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('19', '297035.00', '8950', '0', 'اضافة فاتورة مشتريات', '14074', '305985', '2024-12-12 17:24:31', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','8950','1','300780','8950','309730','0');
update buybill set dailyentryid='0,' where buybillid=14074;
COMMIT;
UPDATE product SET overAllAveragePrice = 400 WHERE productId = 16223;UPDATE product SET overAllAveragePrice = 330 WHERE productId = 16416;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:55:39";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:25:39", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:25:39', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14074');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:57:00";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:27:00", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:27:00', '77', 'bill', '192.168.1.73', '', '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 ('R3336','','1','165','220', '220','220', '2024-12-12', '0', '77', '1', 'R3336', '0', '0', '0', '0', '0', '165','165','165','165','165','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','165','165','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16417, 1,'2024-12-12 17:27:35',77)
                ON DUPLICATE KEY UPDATE productid = 16417, edited = 1, sysdate = '2024-12-12 17:27:35', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16417', '1', '2024-12-12', '77', '0','1641701','220','220','220','165','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16417', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16417', '1', '0', '0', '16417', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','0','0');
UPDATE productunit SET unitid = '1', productid = '16327', productnumber = '1.00', productunitdate = '2024-12-07', userid = '77', conditions = '0',proUnitParcode='1632701',proUnitSellAllPrice='400',proUnitSellHalfPrice='400',proUnitSellUnitPrice ='400',proUnitBuyPrice='355',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16327';
UPDATE product SET productName = '7234', productDescription = '', productCatId = '5', productBuyPrice = '360', productSellAllPrice = '400', productSellUnitPrice = '400', productSellHalfPrice = '400', productDate = '2024-12-07', conditions = '0', userId = '77', limitamount = '1', parcode = '07234',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '355.00',lastbuyprice_withDiscount = '355',meanbuyprice = '357.5',meanbuyprice_withDiscount = '357.5' , productbuypricereal = '355' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='355',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='355',meanbuyprice_withTax='355',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='355'  WHERE productId = '16327';
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 ('7287','','5','495','580', '580','580', '2024-12-12', '0', '77', '1', '07287', '0', '0', '0', '0', '0', '495','495','495','495','495','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','495','495','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16418, 1,'2024-12-12 17:28:09',77)
                ON DUPLICATE KEY UPDATE productid = 16418, edited = 1, sysdate = '2024-12-12 17:28:09', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16418', '1', '2024-12-12', '77', '0','1641801','580','580','580','495','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16418', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16418', '1', '0', '0', '16418', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','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 ('7289','','5','210','260', '260','260', '2024-12-12', '0', '77', '1', '07289', '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 (16419, 1,'2024-12-12 17:28:33',77)
                ON DUPLICATE KEY UPDATE productid = 16419, edited = 1, sysdate = '2024-12-12 17:28: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', '16419', '1', '2024-12-12', '77', '0','1641901','260','260','260','210','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16419', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16419', '1', '0', '0', '16419', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:58:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:28:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:28: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-12 13:58:49";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:28:49", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:28:49', '77', 'add', '192.168.1.73', '', '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 ('0675b00c50304f', '2024-12-12 17:27:01', '80', '255475.00', '274975', '0', '0', '19500',  '19500', '0', '19500', '1', '2024-12-12 17:28: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 ('R3336', '14075', '1', '16417', '15', '165', '2475', '0', '', '2024-12-12 17:28:49', '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-12 17:27:01', 1, 16417, 0, 0
                    , 165, 15, 0, 0, 77, '2024-12-12 17:28:49')
                ON DUPLICATE KEY UPDATE buyprice = 165,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:28:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16417', '165', '15', '0', 'buyBillController.php', '32565', '', '0', '0');
UPDATE product SET  productBuyPrice = "165" WHERE productId = 16417 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32565 ;
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='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='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 = 32565;
UPDATE productunit SET proUnitBuyPrice  = 165 * productnumber WHERE productid = 16417;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16416';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16417', '1', '15', '0', '14075', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-12 17:27:01','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 ('07234', '14075', '5', '16327', '15', '360', '5400', '0', '', '2024-12-12 17:28:49', '16327','','','0','0','0','0','0',null,'360','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-12 17:27:01', 1, 16327, 0, 0
                    , 360, 15, 0, 0, 77, '2024-12-12 17:28:49')
                ON DUPLICATE KEY UPDATE buyprice = 360,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:28:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16327', '360', '15', '0', 'buyBillController.php', '32566', '', '0', '0');
UPDATE product SET  productBuyPrice = "360" WHERE productId = 16327 ;
UPDATE buybilldetail SET  quantitybefore = 11 WHERE buybilldetailid = 32566 ;
UPDATE product SET productName = '7234', productDescription = '', productCatId = '5', productBuyPrice = '360.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '400.00', productDate = '2024-12-07', conditions = '0', userId = '77', limitamount = '1', parcode = '07234',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '360',lastbuyprice_withDiscount = '360',meanbuyprice = '359',meanbuyprice_withDiscount = '359' , productbuypricereal = '355.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='355',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='360',meanbuyprice_withTax='358',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 = '16327';
UPDATE buybilldetail SET  lastbuyprice = 360 , meanbuyprice = 359, lastbuyprice_withDiscount = 360, meanbuyprice_withDiscount = 359
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 358, lastbuyprice_withDiscountAndTax = 360
                where buybilldetailid = 32566;
UPDATE productunit SET proUnitBuyPrice  = 360 * productnumber WHERE productid = 16327;
UPDATE storedetail SET  productquantity = '26', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16326';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16327', '1', '15', '0', '14075', 'اضافة فاتورة مشتريات', 'buyBillController.php', '11', '26', '77', '2024-12-12 17:27:01','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07287', '14075', '5', '16418', '10', '495', '4950', '0', '', '2024-12-12 17:28:49', '16418','','','0','0','0','0','0',null,'495','4950','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-12 17:27:01', 1, 16418, 0, 0
                    , 495, 10, 0, 0, 77, '2024-12-12 17:28:49')
                ON DUPLICATE KEY UPDATE buyprice = 495,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:28:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16418', '495', '10', '0', 'buyBillController.php', '32567', '', '0', '0');
UPDATE product SET  productBuyPrice = "495" WHERE productId = 16418 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32567 ;
UPDATE product SET productName = '7287', productDescription = '', productCatId = '5', productBuyPrice = '495.00', productSellAllPrice = '580.00', productSellUnitPrice = '580.00', productSellHalfPrice = '580.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07287',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '495',lastbuyprice_withDiscount = '495',meanbuyprice = '495',meanbuyprice_withDiscount = '495' , productbuypricereal = '495.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='495',meanbuyprice_withTax='495',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='495'  WHERE productId = '16418';
UPDATE buybilldetail SET  lastbuyprice = 495 , meanbuyprice = 495, lastbuyprice_withDiscount = 495, meanbuyprice_withDiscount = 495
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 495, lastbuyprice_withDiscountAndTax = 495
                where buybilldetailid = 32567;
UPDATE productunit SET proUnitBuyPrice  = 495 * productnumber WHERE productid = 16418;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16417';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16418', '1', '10', '0', '14075', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-12 17:27:01','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07289', '14075', '5', '16419', '15', '210', '3150', '0', '', '2024-12-12 17:28:49', '16419','','','0','0','0','0','0',null,'210','3150','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-12 17:27:01', 1, 16419, 0, 0
                    , 210, 15, 0, 0, 77, '2024-12-12 17:28:49')
                ON DUPLICATE KEY UPDATE buyprice = 210,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:28:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16419', '210', '15', '0', 'buyBillController.php', '32568', '', '0', '0');
UPDATE product SET  productBuyPrice = "210" WHERE productId = 16419 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32568 ;
UPDATE product SET productName = '7289', productDescription = '', productCatId = '5', productBuyPrice = '210.00', productSellAllPrice = '260.00', productSellUnitPrice = '260.00', productSellHalfPrice = '260.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07289',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210',lastbuyprice_withDiscount = '210',meanbuyprice = '210',meanbuyprice_withDiscount = '210' , productbuypricereal = '210.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='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 = '16419';
UPDATE buybilldetail SET  lastbuyprice = 210 , meanbuyprice = 210, lastbuyprice_withDiscount = 210, meanbuyprice_withDiscount = 210
        , lastbuyprice_withTax = 210, meanbuyprice_withTax = 210, lastbuyprice_withDiscountAndTax = 210
                where buybilldetailid = 32568;
UPDATE productunit SET proUnitBuyPrice  = 210 * productnumber WHERE productid = 16419;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16418';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16419', '1', '15', '0', '14075', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-12 17:27:01','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 ('07085', '14075', '5', '16091', '15', '235', '3525', '0', '', '2024-12-12 17:28:49', '16091','','','0','0','0','0','0',null,'235','3525','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-12 17:27:01', 1, 16091, 0, 0
                    , 235, 15, 0, 0, 77, '2024-12-12 17:28:49')
                ON DUPLICATE KEY UPDATE buyprice = 235,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:28:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16091', '235', '15', '0', 'buyBillController.php', '32569', '', '0', '0');
UPDATE product SET  productBuyPrice = "235" WHERE productId = 16091 ;
UPDATE buybilldetail SET  quantitybefore = 12 WHERE buybilldetailid = 32569 ;
UPDATE product SET productName = '7085', productDescription = '', productCatId = '5', productBuyPrice = '235.00', productSellAllPrice = '285.00', productSellUnitPrice = '285.00', productSellHalfPrice = '285.00', productDate = '2024-11-23', conditions = '0', userId = '77', limitamount = '1', parcode = '07085',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '235',lastbuyprice_withDiscount = '235',meanbuyprice = '235',meanbuyprice_withDiscount = '235' , 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='235',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='235',meanbuyprice_withTax='235',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='235'  WHERE productId = '16091';
UPDATE buybilldetail SET  lastbuyprice = 235 , meanbuyprice = 235, lastbuyprice_withDiscount = 235, meanbuyprice_withDiscount = 235
        , lastbuyprice_withTax = 235, meanbuyprice_withTax = 235, lastbuyprice_withDiscountAndTax = 235
                where buybilldetailid = 32569;
UPDATE productunit SET proUnitBuyPrice  = 235 * productnumber WHERE productid = 16091;
UPDATE storedetail SET  productquantity = '27', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16090';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16091', '1', '15', '0', '14075', 'اضافة فاتورة مشتريات', 'buyBillController.php', '12', '27', '77', '2024-12-12 17:27:01','0','0');
UPDATE supplier SET  suppliercurrentDebt = '274975',suppliercurrentDebtInCurrency= '274975' , userid = '77', supplierdate = '2024-12-12 17:28:49'   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', '255475.00', '19500', '0', 'اضافة فاتورة مشتريات', '14075', '274975', '2024-12-12 17:27:01', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','19500','1','255475','19500','274975','0');
update buybill set dailyentryid='0,' where buybillid=14075;
COMMIT;
UPDATE product SET overAllAveragePrice = 235 WHERE productId = 16091;UPDATE product SET overAllAveragePrice = 357.5 WHERE productId = 16327;UPDATE product SET overAllAveragePrice = 165 WHERE productId = 16417;UPDATE product SET overAllAveragePrice = 495 WHERE productId = 16418;UPDATE product SET overAllAveragePrice = 210 WHERE productId = 16419;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:58:50";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:28:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:28:50', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14075');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:59:01";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:29:01", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-12 17:29:01', '77', 'showbarcodebuybill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14075&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:59:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:29:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:29: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 0675b01230ea83
-- ----------------------------------------------------------------------------------------------------

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-12 17:28:35', '0675b01230ea83', '1', '0.00', '0', '0', '1', '810.00', '810', '810', '0', '1', '2024-12-12 17:29:30', '', '104', '0', 'نقدي', '1', '0', '3', '25', 'نقدي', '2' ,'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-12','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','اضافة فاتورة مبيعات','149186', '0', '2024-12-12 17:29:30', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '810', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 17:28:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35556;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1581', '149186', '14', '16144', '1', '530', '530', '0', '', '1', '2024-12-12 17:29:30', '16144', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35556-1,','1','1','0','0','530','530','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
        , lastbuyprice_withTax = 430, meanbuyprice_withTax = 430, lastbuyprice_withDiscountAndTax = 430
                where sellbilldetailid = 545152;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16144, '2024-12-12', 530, 430, 430
                    , 430, 430, 430, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 430, 430, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, 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+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 530, 430, 430
                    , 430, 430, 430, 430
                    , 0, 0, 0, 0
                    , 0, 0, 0, 430, 430, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, 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 = '9', userid = '104', storedetaildate = '2024-12-12 17:29:30' WHERE storedetailid = '16143';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16144', '1', '1', '1', '149186', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-12 17:29:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35618;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1538', '149186', '14', '16012', '1', '280', '280', '0', '', '1', '2024-12-12 17:29:30', '16012', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35618-1,','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 = 545153;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16012, '2024-12-12', 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-12', 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 = '4', userid = '104', storedetaildate = '2024-12-12 17:29:30' WHERE storedetailid = '16011';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16012', '1', '1', '1', '149186', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-12 17:29:30','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '16120',  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 ('15310','810', '0', '1', 'اضافة فاتورة مبيعات', '149186', '16120', '2024-12-12 17:29:30', '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-12', 810, 640, 640
                    , 640, 640, 640, 640
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,640, 640, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+640
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+640
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+640
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+640
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+640
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 810, 640, 640
                    , 640, 640, 640, 640
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,640, 640, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+640
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+640
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+640
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+640
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+640
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 640, 640
                    , 640, 640, 640, 640, 640, 640)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+810, netSellCostBuyPrice = netSellCostBuyPrice+640
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+640
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+640
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+640
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+640
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+640
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+640
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+640;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b01230ea83 and sellbillId = 149186 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:59:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:29:31", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:29: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-12 13:59:56";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:29:56", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-12 17:29:56', '77', 'showbarcodebuybill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14075&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 13:59:58";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:29:58", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:29:58', '77', 'bill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:00:31";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:30:31", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 17:30:31', '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-12 14:00:32";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:00:46";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:30:46", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:30:46', '101', 'addsellBill', '192.168.1.27', '', '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 ('7286','','5','140','200', '200','200', '2024-12-12', '0', '77', '1', '07286', '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 (16420, 1,'2024-12-12 17:30:47',77)
                ON DUPLICATE KEY UPDATE productid = 16420, edited = 1, sysdate = '2024-12-12 17:30:47', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16420', '1', '2024-12-12', '77', '0','1642001','200','200','200','140','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16420', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16420', '1', '0', '0', '16420', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','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 ('7288','','5','140','200', '200','200', '2024-12-12', '0', '77', '1', '07288', '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 (16421, 1,'2024-12-12 17:31:00',77)
                ON DUPLICATE KEY UPDATE productid = 16421, edited = 1, sysdate = '2024-12-12 17:31:00', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16421', '1', '2024-12-12', '77', '0','1642101','200','200','200','140','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16421', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16421', '1', '0', '0', '16421', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','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 ('7283','','5','190','250', '250','250', '2024-12-12', '0', '77', '1', '07283', '0', '0', '0', '0', '0', '190','190','190','190','190','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','190','190','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16422, 1,'2024-12-12 17:31:28',77)
                ON DUPLICATE KEY UPDATE productid = 16422, edited = 1, sysdate = '2024-12-12 17:31:28', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16422', '1', '2024-12-12', '77', '0','1642201','250','250','250','190','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16422', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16422', '1', '0', '0', '16422', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','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 ('7285','','5','190','250', '250','250', '2024-12-12', '0', '77', '1', '07285', '0', '0', '0', '0', '0', '190','190','190','190','190','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','190','190','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16423, 1,'2024-12-12 17:31:52',77)
                ON DUPLICATE KEY UPDATE productid = 16423, edited = 1, sysdate = '2024-12-12 17:31:52', userid = 77;
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice,unitInTax,proUnitPrice4,proUnitPrice5,proUnitPrice6,proUnitPrice7,proUnitPrice8) VALUES ('1', '16423', '1', '2024-12-12', '77', '0','1642301','250','250','250','190','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16423', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16423', '1', '0', '0', '16423', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:02:49";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:32:49", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:32:49', '77', 'add', '192.168.1.73', '', '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 ('0675b01768e606', '2024-12-12 17:29:58', '56', '56320.00', '85420', '0', '0', '29100',  '29100', '0', '29100', '1', '2024-12-12 17:32: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 ('07226', '14076', '5', '16294', '15', '155', '2325', '0', '', '2024-12-12 17:32:49', '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-12 17:29:58', 1, 16294, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-12 17:32:49')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:32:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16294', '155', '15', '0', 'buyBillController.php', '32570', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 16294 ;
UPDATE buybilldetail SET  quantitybefore = 61 WHERE buybilldetailid = 32570 ;
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 = '155',meanbuyprice_withDiscount = '155' , productbuypricereal = '155.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='155',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='155',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='155'  WHERE productId = '16294';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32570;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 16294;
UPDATE storedetail SET  productquantity = '76', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16294', '1', '15', '0', '14076', 'اضافة فاتورة مشتريات', 'buyBillController.php', '61', '76', '77', '2024-12-12 17:29:58','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 ('07220', '14076', '5', '16293', '15', '155', '2325', '0', '', '2024-12-12 17:32:49', '16293','','','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-12 17:29:58', 1, 16293, 0, 0
                    , 155, 15, 0, 0, 77, '2024-12-12 17:32:49')
                ON DUPLICATE KEY UPDATE buyprice = 155,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:32:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16293', '155', '15', '0', 'buyBillController.php', '32571', '', '0', '0');
UPDATE product SET  productBuyPrice = "155" WHERE productId = 16293 ;
UPDATE buybilldetail SET  quantitybefore = 36 WHERE buybilldetailid = 32571 ;
UPDATE product SET productName = '7220', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '1', parcode = '07220',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '155',meanbuyprice_withDiscount = '155' , productbuypricereal = '155.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='155',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='155',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='155'  WHERE productId = '16293';
UPDATE buybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155
        , lastbuyprice_withTax = 155, meanbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where buybilldetailid = 32571;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 16293;
UPDATE storedetail SET  productquantity = '51', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16292';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16293', '1', '15', '0', '14076', 'اضافة فاتورة مشتريات', 'buyBillController.php', '36', '51', '77', '2024-12-12 17:29:58','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 ('07001', '14076', '5', '15970', '15', '140', '2100', '0', '', '2024-12-12 17:32:49', '15970','','','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-12 17:29:58', 1, 15970, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:32:49')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:32:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15970', '140', '15', '0', 'buyBillController.php', '32572', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 15970 ;
UPDATE buybilldetail SET  quantitybefore = 23 WHERE buybilldetailid = 32572 ;
UPDATE product SET productName = '7001', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-11-15', conditions = '0', userId = '77', limitamount = '1', parcode = '07001',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.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='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 = '15970';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 142, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32572;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 15970;
UPDATE storedetail SET  productquantity = '38', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15969';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15970', '1', '15', '0', '14076', 'اضافة فاتورة مشتريات', 'buyBillController.php', '23', '38', '77', '2024-12-12 17:29:58','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 ('07284', '14076', '5', '16415', '15', '140', '2100', '0', '', '2024-12-12 17:32:49', '16415','','','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-12 17:29:58', 1, 16415, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:32:49')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:32:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16415', '140', '15', '0', 'buyBillController.php', '32573', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16415 ;
UPDATE buybilldetail SET  quantitybefore = 15 WHERE buybilldetailid = 32573 ;
UPDATE product SET productName = '7284', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07284',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 = '16415';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32573;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16415;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16414';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16415', '1', '15', '0', '14076', 'اضافة فاتورة مشتريات', 'buyBillController.php', '15', '30', '77', '2024-12-12 17:29:58','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 ('07286', '14076', '5', '16420', '15', '140', '2100', '0', '', '2024-12-12 17:32:49', '16420','','','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-12 17:29:58', 1, 16420, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:32:49')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:32:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16420', '140', '15', '0', 'buyBillController.php', '32574', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16420 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32574 ;
UPDATE product SET productName = '7286', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07286',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 = '16420';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32574;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16420;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16419';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16420', '1', '15', '0', '14076', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-12 17:29:58','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 ('07288', '14076', '5', '16421', '15', '140', '2100', '0', '', '2024-12-12 17:32:49', '16421','','','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-12 17:29:58', 1, 16421, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:32:49')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:32:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16421', '140', '15', '0', 'buyBillController.php', '32575', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 16421 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32575 ;
UPDATE product SET productName = '7288', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07288',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 = '16421';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140
        , lastbuyprice_withTax = 140, meanbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32575;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 16421;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16420';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16421', '1', '15', '0', '14076', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-12 17:29:58','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 ('06675', '14076', '5', '15165', '15', '140', '2100', '0', '', '2024-12-12 17:32:49', '15165','','','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-12 17:29:58', 1, 15165, 0, 0
                    , 140, 15, 0, 0, 77, '2024-12-12 17:32:49')
                ON DUPLICATE KEY UPDATE buyprice = 140,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:32:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15165', '140', '15', '0', 'buyBillController.php', '32576', '', '0', '0');
UPDATE product SET  productBuyPrice = "140" WHERE productId = 15165 ;
UPDATE buybilldetail SET  quantitybefore = -15 WHERE buybilldetailid = 32576 ;
UPDATE product SET productName = '6675', productDescription = '', productCatId = '5', productBuyPrice = '140.00', productSellAllPrice = '200.00', productSellUnitPrice = '200.00', productSellHalfPrice = '200.00', productDate = '2024-09-20', conditions = '0', userId = '77', limitamount = '1', parcode = '06675',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '140',lastbuyprice_withDiscount = '140',meanbuyprice = '140.00',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='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='140'  WHERE productId = '15165';
UPDATE buybilldetail SET  lastbuyprice = 140 , meanbuyprice = 140.00, lastbuyprice_withDiscount = 140, meanbuyprice_withDiscount = 140.00
        , lastbuyprice_withTax = 140, lastbuyprice_withDiscountAndTax = 140
                where buybilldetailid = 32576;
UPDATE productunit SET proUnitBuyPrice  = 140 * productnumber WHERE productid = 15165;
UPDATE storedetail SET  productquantity = '0', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15164';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15165', '1', '15', '0', '14076', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-15', '0', '77', '2024-12-12 17:29:58','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 ('07283', '14076', '5', '16422', '15', '190', '2850', '0', '', '2024-12-12 17:32:49', '16422','','','0','0','0','0','0',null,'190','2850','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-12 17:29:58', 1, 16422, 0, 0
                    , 190, 15, 0, 0, 77, '2024-12-12 17:32:49')
                ON DUPLICATE KEY UPDATE buyprice = 190,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:32:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16422', '190', '15', '0', 'buyBillController.php', '32577', '', '0', '0');
UPDATE product SET  productBuyPrice = "190" WHERE productId = 16422 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32577 ;
UPDATE product SET productName = '7283', productDescription = '', productCatId = '5', productBuyPrice = '190.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '250.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07283',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '190',lastbuyprice_withDiscount = '190',meanbuyprice = '190',meanbuyprice_withDiscount = '190' , productbuypricereal = '190.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='190',meanbuyprice_withTax='190',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='190'  WHERE productId = '16422';
UPDATE buybilldetail SET  lastbuyprice = 190 , meanbuyprice = 190, lastbuyprice_withDiscount = 190, meanbuyprice_withDiscount = 190
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 190, lastbuyprice_withDiscountAndTax = 190
                where buybilldetailid = 32577;
UPDATE productunit SET proUnitBuyPrice  = 190 * productnumber WHERE productid = 16422;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16421';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16422', '1', '15', '0', '14076', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-12 17:29:58','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 ('07285', '14076', '5', '16423', '15', '190', '2850', '0', '', '2024-12-12 17:32:49', '16423','','','0','0','0','0','0',null,'190','2850','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-12 17:29:58', 1, 16423, 0, 0
                    , 190, 15, 0, 0, 77, '2024-12-12 17:32:49')
                ON DUPLICATE KEY UPDATE buyprice = 190,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:32:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16423', '190', '15', '0', 'buyBillController.php', '32578', '', '0', '0');
UPDATE product SET  productBuyPrice = "190" WHERE productId = 16423 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32578 ;
UPDATE product SET productName = '7285', productDescription = '', productCatId = '5', productBuyPrice = '190.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '250.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07285',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '190',lastbuyprice_withDiscount = '190',meanbuyprice = '190',meanbuyprice_withDiscount = '190' , productbuypricereal = '190.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='190',meanbuyprice_withTax='190',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='190'  WHERE productId = '16423';
UPDATE buybilldetail SET  lastbuyprice = 190 , meanbuyprice = 190, lastbuyprice_withDiscount = 190, meanbuyprice_withDiscount = 190
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 190, lastbuyprice_withDiscountAndTax = 190
                where buybilldetailid = 32578;
UPDATE productunit SET proUnitBuyPrice  = 190 * productnumber WHERE productid = 16423;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16422';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16423', '1', '15', '0', '14076', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-12 17:29:58','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', '14076', '1', '15411', '15', '550', '8250', '0', '', '2024-12-12 17:32:49', '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-12 17:29:58', 1, 15411, 0, 0
                    , 550, 15, 0, 0, 77, '2024-12-12 17:32:49')
                ON DUPLICATE KEY UPDATE buyprice = 550,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:32:49' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15411', '550', '15', '0', 'buyBillController.php', '32579', '', '0', '0');
UPDATE product SET  productBuyPrice = "550" WHERE productId = 15411 ;
UPDATE buybilldetail SET  quantitybefore = 44 WHERE buybilldetailid = 32579 ;
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 = '546',meanbuyprice_withDiscount = '546' , 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='476.36',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='407',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 = 546, lastbuyprice_withDiscount = 550, meanbuyprice_withDiscount = 546
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 407, lastbuyprice_withDiscountAndTax = 550
                where buybilldetailid = 32579;
UPDATE productunit SET proUnitBuyPrice  = 550 * productnumber WHERE productid = 15411;
UPDATE storedetail SET  productquantity = '59', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15410';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15411', '1', '15', '0', '14076', 'اضافة فاتورة مشتريات', 'buyBillController.php', '44', '59', '77', '2024-12-12 17:29:58','0','0');
UPDATE supplier SET  suppliercurrentDebt = '85420',suppliercurrentDebtInCurrency= '85420' , userid = '77', supplierdate = '2024-12-12 17:32:49'   WHERE supplierid = '56';
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,debtchangbeforeInSupplierCurrency,debtchangamountInSupplierCurrency,debtchangafterInSupplierCurrency,paySerialNo) VALUES ('56', '56320.00', '29100', '0', 'اضافة فاتورة مشتريات', '14076', '85420', '2024-12-12 17:29:58', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','29100','1','56320','29100','85420','0');
update buybill set dailyentryid='0,' where buybillid=14076;
COMMIT;
UPDATE product SET overAllAveragePrice = 140 WHERE productId = 15165;UPDATE product SET overAllAveragePrice = 485.2 WHERE productId = 15411;UPDATE product SET overAllAveragePrice = 140.45 WHERE productId = 15970;UPDATE product SET overAllAveragePrice = 155 WHERE productId = 16293;UPDATE product SET overAllAveragePrice = 155 WHERE productId = 16294;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16415;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16420;UPDATE product SET overAllAveragePrice = 140 WHERE productId = 16421;UPDATE product SET overAllAveragePrice = 190 WHERE productId = 16422;UPDATE product SET overAllAveragePrice = 190 WHERE productId = 16423;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:02:50";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:32:50", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:32:50', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14076');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:02:54";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:32:54", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-12 17:32:54', '77', 'showbarcodebuybill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14076&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:04:19";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:34:19", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-12 17:34:19', '77', 'showbarcodebuybill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14076&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:04:21";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:34:21", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:34:21', '77', 'bill', '192.168.1.73', '', '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 ('H1658','','14','180','250', '250','250', '2024-12-12', '0', '77', '1', 'H1658', '0', '0', '0', '0', '0', '180','180','180','180','180','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','180','180','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16424, 1,'2024-12-12 17:34:54',77)
                ON DUPLICATE KEY UPDATE productid = 16424, edited = 1, sysdate = '2024-12-12 17:34: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', '16424', '1', '2024-12-12', '77', '0','1642401','250','250','250','180','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16424', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16424', '1', '0', '0', '16424', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:05:02";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:35:02", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:35:02', '77', 'add', '192.168.1.73', '', '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 ('0675b027d78250', '2024-12-12 17:34:21', '9', '275825.00', '279425', '0', '0', '3600',  '3600', '0', '3600', '1', '2024-12-12 17:35:02', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('H1658', '14077', '14', '16424', '20', '180', '3600', '0', '', '2024-12-12 17:35:02', '16424','','','0','0','0','0','0',null,'180','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-12 17:34:21', 1, 16424, 0, 0
                    , 180, 20, 0, 0, 77, '2024-12-12 17:35:02')
                ON DUPLICATE KEY UPDATE buyprice = 180,
                        buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:35:02' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16424', '180', '20', '0', 'buyBillController.php', '32580', '', '0', '0');
UPDATE product SET  productBuyPrice = "180" WHERE productId = 16424 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32580 ;
UPDATE product SET productName = 'H1658', productDescription = '', productCatId = '14', productBuyPrice = '180.00', productSellAllPrice = '250.00', productSellUnitPrice = '250.00', productSellHalfPrice = '250.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1658',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '180',lastbuyprice_withDiscount = '180',meanbuyprice = '180',meanbuyprice_withDiscount = '180' , productbuypricereal = '180.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='180',meanbuyprice_withTax='180',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='180'  WHERE productId = '16424';
UPDATE buybilldetail SET  lastbuyprice = 180 , meanbuyprice = 180, lastbuyprice_withDiscount = 180, meanbuyprice_withDiscount = 180
        , lastbuyprice_withTax = 180, meanbuyprice_withTax = 180, lastbuyprice_withDiscountAndTax = 180
                where buybilldetailid = 32580;
UPDATE productunit SET proUnitBuyPrice  = 180 * productnumber WHERE productid = 16424;
UPDATE storedetail SET  productquantity = '20', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16423';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16424', '1', '20', '0', '14077', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '20', '77', '2024-12-12 17:34:21','0','0');
UPDATE supplier SET  suppliercurrentDebt = '279685',suppliercurrentDebtInCurrency= '279425' , userid = '77', supplierdate = '2024-12-12 17:35:02'   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', '276085.00', '3600', '0', 'اضافة فاتورة مشتريات', '14077', '279685', '2024-12-12 17:34:21', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','3600','1','275825','3600','279425','0');
update buybill set dailyentryid='0,' where buybillid=14077;
COMMIT;
UPDATE product SET overAllAveragePrice = 180 WHERE productId = 16424;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:05:02";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:35:02", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:35:02', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14077');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:05:06";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:35:06", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-12 17:35:06', '77', 'showbarcodebuybill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14077&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:05:27";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:35:27", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-12 17:35:27', '77', 'showbarcodebuybill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14077&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:05:29";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:35:29", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:35:29', '77', 'bill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=1');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:05:46";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 17:35:46", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:35: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 0675affa337bd0
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2117,@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-12 17:22:11', '0675affa337bd0', '2117', '0.00', '1576', '0', '1', '1576.00', '1576', '0', '1576', '1', '2024-12-12 17:35:47', '', '75', '0', 'اية علاء الدين w301', '2', '1', '3', '85', 'اية علاء الدين w301', '5' ,'0','','','','','-1','0','0','0','0','0','1576','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1576', userid = '75' WHERE clientid = '2117';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2117','0.00','1576','0','اضافة فاتورة مبيعات','149187', '1576', '2024-12-12 17:35:47', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1576', '0', null, '0', null, null,'', '0','1','1','1576','1','2024-12-12 17:22:11','0','0');
UPDATE client SET  inUse = 0 where clientid = 2117;
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', '149187', '5', '16297', '1', '580', '580', '0', '', '1', '2024-12-12 17:35:47', '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 = 545154;
 INSERT INTO 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-12', 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-12', 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 = '70', userid = '75', storedetaildate = '2024-12-12 17:35:47' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '1', '149187', 'اضافة فاتورة مبيعات', 'sellbillController.php', '71', '70', '75', '2024-12-12 17:35:47','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35858;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149187', '5', '15995', '2', '480', '960', '0', '', '1', '2024-12-12 17:35:47', '15995', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35858-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 = 545155;
 INSERT INTO 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-12', 960, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+960, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 960, 840, 840
                    , 840, 840, 840, 840
                    , 0, 0, 0, 0
                    , 0, 0, 0, 840, 840, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+960, sellCostBuyPrice =sellCostBuyPrice+840
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+840, sellCostMeanBuyPrice = sellCostMeanBuyPrice+840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+840, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+840
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+840
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+840
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+840
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '103', userid = '75', storedetaildate = '2024-12-12 17:35:47' WHERE storedetailid = '15994';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15995', '1', '2', '1', '149187', 'اضافة فاتورة مبيعات', 'sellbillController.php', '105', '103', '75', '2024-12-12 17:35: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', '149187', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 17:35: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', '149187', '17', '10291', '1', '16', '16', '0', '', '1', '2024-12-12 17:35:47', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','16','16','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 85 where clientid = 2117;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1576, 1350, 1350
                    , 1350, 1350, 1350, 1350
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1350, 1350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1576, sellCostBuyPrice =sellCostBuyPrice+1350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2117, '2024-12-12', 1576, 1350, 1350
                    , 1350, 1350, 1350, 1350
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1350, 1350, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1576, sellCostBuyPrice =sellCostBuyPrice+1350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1350
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1350
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1350
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1576, 1350, 1350
                    , 1350, 1350, 1350, 1350, 1350, 1350)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1576, netSellCostBuyPrice = netSellCostBuyPrice+1350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1350
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1350
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1350
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1350
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1350
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1350
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1350;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675affa337bd0 and sellbillId = 149187 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:05:47";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 17:35:48", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:35: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-12 14:06:41";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:36:41", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:36:41', '77', 'add', '192.168.1.73', '', '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 ('0675b02c177326', '2024-12-12 17:35:29', '52', '108200.00', '114100', '0', '0', '5900',  '5900', '0', '5900', '1', '2024-12-12 17:36:41', '', '77', '0', '', '1','1','1','0.00','-1','0','0','1','0','0','.','0','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('23664', '14078', '5', '15673', '20', '295', '5900', '0', '', '2024-12-12 17:36:41', '15673','','','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-12 17:35:29', 1, 15673, 0, 0
                    , 295, 20, 0, 0, 77, '2024-12-12 17:36:41')
                ON DUPLICATE KEY UPDATE buyprice = 295,
                        buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:36:41' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15673', '295', '20', '0', 'buyBillController.php', '32581', '', '0', '0');
UPDATE product SET  productBuyPrice = "295" WHERE productId = 15673 ;
UPDATE buybilldetail SET  quantitybefore = 18 WHERE buybilldetailid = 32581 ;
UPDATE product SET productName = '6872', productDescription = '', productCatId = '5', productBuyPrice = '295.00', productSellAllPrice = '360.00', productSellUnitPrice = '360.00', productSellHalfPrice = '360.00', productDate = '2024-10-25', conditions = '0', userId = '77', limitamount = '1', parcode = '23664',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '295',lastbuyprice_withDiscount = '295',meanbuyprice = '295',meanbuyprice_withDiscount = '295' , productbuypricereal = '295.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='295',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='295',meanbuyprice_withTax='295',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='295'  WHERE productId = '15673';
UPDATE buybilldetail SET  lastbuyprice = 295 , meanbuyprice = 295, lastbuyprice_withDiscount = 295, meanbuyprice_withDiscount = 295
        , lastbuyprice_withTax = 295, meanbuyprice_withTax = 295, lastbuyprice_withDiscountAndTax = 295
                where buybilldetailid = 32581;
UPDATE productunit SET proUnitBuyPrice  = 295 * productnumber WHERE productid = 15673;
UPDATE storedetail SET  productquantity = '38', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15672';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15673', '1', '20', '0', '14078', 'اضافة فاتورة مشتريات', 'buyBillController.php', '18', '38', '77', '2024-12-12 17:35:29','0','0');
UPDATE supplier SET  suppliercurrentDebt = '102300',suppliercurrentDebtInCurrency= '114100' , userid = '77', supplierdate = '2024-12-12 17:36:41'   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', '96400.00', '5900', '0', 'اضافة فاتورة مشتريات', '14078', '102300', '2024-12-12 17:35:29', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','5900','1','108200','5900','114100','0');
update buybill set dailyentryid='0,' where buybillid=14078;
COMMIT;
UPDATE product SET overAllAveragePrice = 295 WHERE productId = 15673;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:06:42";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:36:42", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:36:42', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14078');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:06:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:36:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:36: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-12 14:07:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:37:14", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:37: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 0675b0310e1c8c
-- ----------------------------------------------------------------------------------------------------

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-12 17:36:48', '0675b0310e1c8c', '1', '0.00', '0', '0', '1', '580', '580', '-580', '0', '1', '2024-12-12 17:37:15', '', '104', '0', 'نقدي','1', '0', '5', '95', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-580','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','اضافة فاتورة مردوات مبيعات','16742', '0', '2024-12-12 17:37:15', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '580', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 17:36:48','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', '07197', '16742', '5', '16297', '1', '580', '580', '0', '', '1', '0', '16297', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','580','580','0','','0');
UPDATE returnsellbilldetail 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 returnsellbilldetailid = 21902;
 INSERT INTO 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 580, 510, 510, 510
                    , 510, 510, 510, 0, 1, 0, 0, 510, 510)
                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+580, returnSellCostBuyPrice = returnSellCostBuyPrice+510, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+510
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+510, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+510
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+510
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+510
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+510
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+510
                        , 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 580, 510, 510, 510
                    , 510, 510, 510, 0, 0, 510, 510)
                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+580, returnSellCostBuyPrice = returnSellCostBuyPrice+510, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+510
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+510, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+510
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+510
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+510
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+510
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+510;
UPDATE storedetail SET  productquantity = '71', userid = '104', storedetaildate = '2024-12-12 17:37:15' WHERE storedetailid = '16296';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16297', '1', '1', '0', '16742', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '70', '71', '104', '2024-12-12 17:37:15','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '15540',  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 ('16120','-580', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16742', '15540', '2024-12-12 17:37:15', '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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 580, 510, 510, 510
                    , 510, 510, 510 ,0, 0, 510, 510)
                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+580, returnSellCostBuyPrice = returnSellCostBuyPrice+510, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+510
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+510, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+510
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+510
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+510
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+510
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+510;
 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 580, 510, 510, 510
                    , 510, 510, 510 ,0, 0, 510, 510)
                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+580, returnSellCostBuyPrice = returnSellCostBuyPrice+510, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+510
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+510, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+510
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+510
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+510
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+510
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+510;
 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 0675b0310e1c8c and sellbillId = 16742 and returnsellbillId = 16742
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:07:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:37:15", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:37:15', '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-12 14:07:28";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:37:28", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:37:28', '77', 'bill', '192.168.1.73', '', '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 ('H1657','','14','680','800', '800','800', '2024-12-12', '0', '77', '1', 'H1657', '0', '0', '0', '0', '0', '680','680','680','680','680','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','680','680','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16425, 1,'2024-12-12 17:37:54',77)
                ON DUPLICATE KEY UPDATE productid = 16425, edited = 1, sysdate = '2024-12-12 17:37: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', '16425', '1', '2024-12-12', '77', '0','1642501','800','800','800','680','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16425', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16425', '1', '0', '0', '16425', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:07:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:37:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:37:59', '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 ('7290','','5','500','600', '600','600', '2024-12-12', '0', '77', '1', '07290', '0', '0', '0', '0', '0', '500','500','500','500','500','0','0','0','0','','0','0','0','0','0','','','0','0','0','','0','0','0','','','','0','0','0','0','','0','0','','0','','500','500','0','0','0','0','0','0','0','0','0','0','0','0','0','0','','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (16426, 1,'2024-12-12 17:38:22',77)
                ON DUPLICATE KEY UPDATE productid = 16426, edited = 1, sysdate = '2024-12-12 17:38: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', '16426', '1', '2024-12-12', '77', '0','1642601','600','600','600','500','','0','0','0','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('16426', '1', '0', '77', '2024-12-12');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16426', '1', '0', '0', '16426', 'إضافة منتج', 'productController.php', '0', '0', '77', '2024-12-12','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:08:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:38:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:38: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 0675b03576922f
-- ----------------------------------------------------------------------------------------------------

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-12 17:37:59', '0675b03576922f', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-12 17:38:46', '', '104', '0', 'نقدي', '1', '0', '3', '21', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149188', '0', '2024-12-12 17:38:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 17:37:59','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35929;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('250','07200', '149188', '5', '16305', '1', '300', '300', '0', '', '1', '2024-12-12 17:38:46', '16305', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35929-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 250, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 545158;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16305, '2024-12-12', 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-12', 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-12 17:38:46' WHERE storedetailid = '16304';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16305', '1', '1', '1', '149188', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '104', '2024-12-12 17:38:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '15840',  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 ('15540','300', '0', '1', 'اضافة فاتورة مبيعات', '149188', '15840', '2024-12-12 17:38:46', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 21 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 300, 250, 250
                    , 250, 250, 250, 250, 250, 250)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, netSellCostBuyPrice = netSellCostBuyPrice+250
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+250
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+250
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+250
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+250
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+250
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+250
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+250;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b03576922f and sellbillId = 149188 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:08:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:38:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:38:47', '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 = '16426', productnumber = '1.00', productunitdate = '2024-12-12', userid = '77', conditions = '0',proUnitParcode='1642601',proUnitSellAllPrice='600',proUnitSellHalfPrice='600',proUnitSellUnitPrice ='600',proUnitBuyPrice='500',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '16426';
UPDATE product SET productName = '7290', productDescription = '', productCatId = '5', productBuyPrice = '360', productSellAllPrice = '420', productSellUnitPrice = '420', productSellHalfPrice = '420', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07290',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '500.00',lastbuyprice_withDiscount = '500',meanbuyprice = '430',meanbuyprice_withDiscount = '430' , productbuypricereal = '500' , 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='500',meanbuyprice_withTax='500',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='0'  WHERE productId = '16426';
UPDATE productunit SET unitid = '1', productid = '15635', productnumber = '1.00', productunitdate = '2024-10-24', userid = '77', conditions = '0',proUnitParcode='1563501',proUnitSellAllPrice='300',proUnitSellHalfPrice='300',proUnitSellUnitPrice ='300',proUnitBuyPrice='250',unitInTax='',proUnitPrice4='0',proUnitPrice5='0',proUnitPrice6='0',proUnitPrice7='0',proUnitPrice8='0' WHERE productunitid = '15635';
UPDATE product SET productName = '6861', productDescription = '', productCatId = '5', productBuyPrice = '240', productSellAllPrice = '300', productSellUnitPrice = '300', productSellHalfPrice = '300', productDate = '2024-10-24', conditions = '0', userId = '77', limitamount = '0', parcode = '06861',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '250.00',lastbuyprice_withDiscount = '250',meanbuyprice = '271',meanbuyprice_withDiscount = '271' , productbuypricereal = '240' , buypricereal_precentage = '0' , buytotal_precentage = '25' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='236',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='250',meanbuyprice_withTax='432',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='250'  WHERE productId = '15635';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:10:32";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:40:32", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:40:32', '77', 'add', '192.168.1.73', '', '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 ('0675b0338f0465', '2024-12-12 17:37:28', '13', '44935.00', '94085', '0', '0', '49150',  '49150', '0', '49150', '1', '2024-12-12 17:40:33', '', '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 ('H1657', '14079', '14', '16425', '10', '680', '6800', '0', '', '2024-12-12 17:40:33', '16425','','','0','0','0','0','0',null,'680','6800','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-12 17:37:28', 1, 16425, 0, 0
                    , 680, 10, 0, 0, 77, '2024-12-12 17:40:33')
                ON DUPLICATE KEY UPDATE buyprice = 680,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:40:33' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16425', '680', '10', '0', 'buyBillController.php', '32582', '', '0', '0');
UPDATE product SET  productBuyPrice = "680" WHERE productId = 16425 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32582 ;
UPDATE product SET productName = 'H1657', productDescription = '', productCatId = '14', productBuyPrice = '680.00', productSellAllPrice = '800.00', productSellUnitPrice = '800.00', productSellHalfPrice = '800.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1657',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '680',lastbuyprice_withDiscount = '680',meanbuyprice = '680',meanbuyprice_withDiscount = '680' , productbuypricereal = '680.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='680',meanbuyprice_withTax='680',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='680'  WHERE productId = '16425';
UPDATE buybilldetail SET  lastbuyprice = 680 , meanbuyprice = 680, lastbuyprice_withDiscount = 680, meanbuyprice_withDiscount = 680
        , lastbuyprice_withTax = 680, meanbuyprice_withTax = 680, lastbuyprice_withDiscountAndTax = 680
                where buybilldetailid = 32582;
UPDATE productunit SET proUnitBuyPrice  = 680 * productnumber WHERE productid = 16425;
UPDATE storedetail SET  productquantity = '10', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16424';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16425', '1', '10', '0', '14079', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '10', '77', '2024-12-12 17:37:28','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('R3205', '14079', '1', '15411', '15', '550', '8250', '0', '', '2024-12-12 17:40:33', '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-12 17:37:28', 1, 15411, 0, 0
                    , 550, 15, 0, 0, 77, '2024-12-12 17:40:33')
                ON DUPLICATE KEY UPDATE buyprice = 550,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:40:33' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15411', '550', '15', '0', 'buyBillController.php', '32583', '', '0', '0');
UPDATE product SET  productBuyPrice = "550" WHERE productId = 15411 ;
UPDATE buybilldetail SET  quantitybefore = 59 WHERE buybilldetailid = 32583 ;
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 = '547',meanbuyprice_withDiscount = '547' , 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='485.2',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='436',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 = 547, lastbuyprice_withDiscount = 550, meanbuyprice_withDiscount = 547
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 436, lastbuyprice_withDiscountAndTax = 550
                where buybilldetailid = 32583;
UPDATE productunit SET proUnitBuyPrice  = 550 * productnumber WHERE productid = 15411;
UPDATE storedetail SET  productquantity = '74', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15410';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15411', '1', '15', '0', '14079', 'اضافة فاتورة مشتريات', 'buyBillController.php', '59', '74', '77', '2024-12-12 17:37:28','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07227', '14079', '5', '16282', '10', '550', '5500', '0', '', '2024-12-12 17:40:33', '16282','','','0','0','0','0','0',null,'550','5500','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-12 17:37:28', 1, 16282, 0, 0
                    , 550, 10, 0, 0, 77, '2024-12-12 17:40:33')
                ON DUPLICATE KEY UPDATE buyprice = 550,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:40:33' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16282', '550', '10', '0', 'buyBillController.php', '32584', '', '0', '0');
UPDATE product SET  productBuyPrice = "550" WHERE productId = 16282 ;
UPDATE buybilldetail SET  quantitybefore = 7 WHERE buybilldetailid = 32584 ;
UPDATE product SET productName = '7227', productDescription = '', productCatId = '5', productBuyPrice = '550.00', productSellAllPrice = '600.00', productSellUnitPrice = '600.00', productSellHalfPrice = '600.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '1', parcode = '07227',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '550',lastbuyprice_withDiscount = '550',meanbuyprice = '550',meanbuyprice_withDiscount = '550' , productbuypricereal = '550.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='550',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='550',meanbuyprice_withTax='437',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 = '16282';
UPDATE buybilldetail SET  lastbuyprice = 550 , meanbuyprice = 550, lastbuyprice_withDiscount = 550, meanbuyprice_withDiscount = 550
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 437, lastbuyprice_withDiscountAndTax = 550
                where buybilldetailid = 32584;
UPDATE productunit SET proUnitBuyPrice  = 550 * productnumber WHERE productid = 16282;
UPDATE storedetail SET  productquantity = '17', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16281';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16282', '1', '10', '0', '14079', 'اضافة فاتورة مشتريات', 'buyBillController.php', '7', '17', '77', '2024-12-12 17:37:28','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07290', '14079', '5', '16426', '15', '360', '5400', '0', '', '2024-12-12 17:40:33', '16426','','','0','0','0','0','0',null,'360','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-12 17:37:28', 1, 16426, 0, 0
                    , 360, 15, 0, 0, 77, '2024-12-12 17:40:33')
                ON DUPLICATE KEY UPDATE buyprice = 360,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:40:33' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16426', '360', '15', '0', 'buyBillController.php', '32585', '', '0', '0');
UPDATE product SET  productBuyPrice = "360" WHERE productId = 16426 ;
UPDATE buybilldetail SET  quantitybefore = 0 WHERE buybilldetailid = 32585 ;
UPDATE product SET productName = '7290', productDescription = '', productCatId = '5', productBuyPrice = '360.00', productSellAllPrice = '420.00', productSellUnitPrice = '420.00', productSellHalfPrice = '420.00', productDate = '2024-12-12', conditions = '0', userId = '77', limitamount = '1', parcode = '07290',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '360',lastbuyprice_withDiscount = '360',meanbuyprice = '360',meanbuyprice_withDiscount = '360' , productbuypricereal = '500.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='360',meanbuyprice_withTax='360',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='360'  WHERE productId = '16426';
UPDATE buybilldetail SET  lastbuyprice = 360 , meanbuyprice = 360, lastbuyprice_withDiscount = 360, meanbuyprice_withDiscount = 360
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 360, lastbuyprice_withDiscountAndTax = 360
                where buybilldetailid = 32585;
UPDATE productunit SET proUnitBuyPrice  = 360 * productnumber WHERE productid = 16426;
UPDATE storedetail SET  productquantity = '15', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16425';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16426', '1', '15', '0', '14079', 'اضافة فاتورة مشتريات', 'buyBillController.php', '0', '15', '77', '2024-12-12 17:37:28','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07257', '14079', '5', '16373', '20', '550', '11000', '0', '', '2024-12-12 17:40:33', '16373','','','0','0','0','0','0',null,'550','11000','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-12 17:37:28', 1, 16373, 0, 0
                    , 550, 20, 0, 0, 77, '2024-12-12 17:40:33')
                ON DUPLICATE KEY UPDATE buyprice = 550,
                        buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:40:33' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16373', '550', '20', '0', 'buyBillController.php', '32586', '', '0', '0');
UPDATE product SET  productBuyPrice = "550" WHERE productId = 16373 ;
UPDATE buybilldetail SET  quantitybefore = 20 WHERE buybilldetailid = 32586 ;
UPDATE product SET productName = '7257', productDescription = '', productCatId = '5', productBuyPrice = '550.00', productSellAllPrice = '620.00', productSellUnitPrice = '620.00', productSellHalfPrice = '620.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07257',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '550',lastbuyprice_withDiscount = '550',meanbuyprice = '550',meanbuyprice_withDiscount = '550' , productbuypricereal = '550.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='550',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='550',meanbuyprice_withTax='550',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='550'  WHERE productId = '16373';
UPDATE buybilldetail SET  lastbuyprice = 550 , meanbuyprice = 550, lastbuyprice_withDiscount = 550, meanbuyprice_withDiscount = 550
        , lastbuyprice_withTax = 550, meanbuyprice_withTax = 550, lastbuyprice_withDiscountAndTax = 550
                where buybilldetailid = 32586;
UPDATE productunit SET proUnitBuyPrice  = 550 * productnumber WHERE productid = 16373;
UPDATE storedetail SET  productquantity = '40', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16372';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16373', '1', '20', '0', '14079', 'اضافة فاتورة مشتريات', 'buyBillController.php', '20', '40', '77', '2024-12-12 17:37:28','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06861', '14079', '5', '15635', '15', '240', '3600', '0', '', '2024-12-12 17:40:33', '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-12 17:37:28', 1, 15635, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-12 17:40:33')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:40:33' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15635', '240', '15', '0', 'buyBillController.php', '32587', '', '0', '0');
UPDATE product SET  productBuyPrice = "240" WHERE productId = 15635 ;
UPDATE buybilldetail SET  quantitybefore = 1 WHERE buybilldetailid = 32587 ;
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 = '242',meanbuyprice_withDiscount = '242' , 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',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='252',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 = 242, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 242
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 252, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32587;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 15635;
UPDATE storedetail SET  productquantity = '16', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15634';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15635', '1', '15', '0', '14079', 'اضافة فاتورة مشتريات', 'buyBillController.php', '1', '16', '77', '2024-12-12 17:37:28','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('06603', '14079', '5', '15038', '15', '240', '3600', '0', '', '2024-12-12 17:40:33', '15038','','','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-12 17:37:28', 1, 15038, 0, 0
                    , 240, 15, 0, 0, 77, '2024-12-12 17:40:33')
                ON DUPLICATE KEY UPDATE buyprice = 240,
                        buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:40:33' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('15038', '240', '15', '0', 'buyBillController.php', '32588', '', '0', '0');
UPDATE product SET  productBuyPrice = "240" WHERE productId = 15038 ;
UPDATE buybilldetail SET  quantitybefore = -9 WHERE buybilldetailid = 32588 ;
UPDATE product SET productName = '6603', productDescription = '', productCatId = '5', productBuyPrice = '240.00', productSellAllPrice = '290.00', productSellUnitPrice = '290.00', productSellHalfPrice = '290.00', productDate = '2024-09-14', conditions = '0', userId = '77', limitamount = '0', parcode = '06603',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '240',lastbuyprice_withDiscount = '240',meanbuyprice = '248',meanbuyprice_withDiscount = '248' , productbuypricereal = '230.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '25.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='239.33',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='249',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 = '15038';
UPDATE buybilldetail SET  lastbuyprice = 240 , meanbuyprice = 248, lastbuyprice_withDiscount = 240, meanbuyprice_withDiscount = 248
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 249, lastbuyprice_withDiscountAndTax = 240
                where buybilldetailid = 32588;
UPDATE productunit SET proUnitBuyPrice  = 240 * productnumber WHERE productid = 15038;
UPDATE storedetail SET  productquantity = '6', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '15037';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15038', '1', '15', '0', '14079', 'اضافة فاتورة مشتريات', 'buyBillController.php', '-9', '6', '77', '2024-12-12 17:37:28','0','0');
INSERT INTO buybilldetail (Parcode, buybillid, buybilldetailcatid, buybilldetailproductid, buybilldetailquantity, buybilldetailprice, buybilldetailtotalprice, discountvalue, note, buybilldetaildate, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,quantitybefore, buybilldetailpriceC, buybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,probuyDiscountPer,lastbuyprice_withDiscountAndTax) VALUES ('07273', '14079', '5', '16395', '10', '500', '5000', '0', '', '2024-12-12 17:40:33', '16395','','','0','0','0','0','0',null,'500','5000','0','0','0','0','0','0','0','0');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-12-12 17:37:28', 1, 16395, 0, 0
                    , 500, 10, 0, 0, 77, '2024-12-12 17:40:33')
                ON DUPLICATE KEY UPDATE buyprice = 500,
                        buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 77,sysDate = '2024-12-12 17:40:33' ;
INSERT INTO entryproductspurchased (productid, price, productquantity, soldquantity, tablename, modelid, expirationDate, priority, del) VALUES ('16395', '500', '10', '0', 'buyBillController.php', '32589', '', '0', '0');
UPDATE product SET  productBuyPrice = "500" WHERE productId = 16395 ;
UPDATE buybilldetail SET  quantitybefore = 20 WHERE buybilldetailid = 32589 ;
UPDATE product SET productName = '7273', productDescription = '', productCatId = '5', productBuyPrice = '500.00', productSellAllPrice = '580.00', productSellUnitPrice = '580.00', productSellHalfPrice = '580.00', productDate = '2024-12-11', conditions = '0', userId = '77', limitamount = '1', parcode = '07273',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '500',lastbuyprice_withDiscount = '500',meanbuyprice = '498',meanbuyprice_withDiscount = '498' , productbuypricereal = '510.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='500',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='500',meanbuyprice_withTax='500',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='500'  WHERE productId = '16395';
UPDATE buybilldetail SET  lastbuyprice = 500 , meanbuyprice = 498, lastbuyprice_withDiscount = 500, meanbuyprice_withDiscount = 498
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 500, lastbuyprice_withDiscountAndTax = 500
                where buybilldetailid = 32589;
UPDATE productunit SET proUnitBuyPrice  = 500 * productnumber WHERE productid = 16395;
UPDATE storedetail SET  productquantity = '30', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16394';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16395', '1', '10', '0', '14079', 'اضافة فاتورة مشتريات', 'buyBillController.php', '20', '30', '77', '2024-12-12 17:37:28','0','0');
UPDATE supplier SET  suppliercurrentDebt = '94085',suppliercurrentDebtInCurrency= '94085' , userid = '77', supplierdate = '2024-12-12 17:40:33'   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', '44935.00', '49150', '0', 'اضافة فاتورة مشتريات', '14079', '94085', '2024-12-12 17:37:28', '77', 'buyBillController.php', 'اضافة فاتورة مشتريات', '0','', '0','1','1','49150','1','44935','49150','94085','0');
update buybill set dailyentryid='0,' where buybillid=14079;
COMMIT;
UPDATE product SET overAllAveragePrice = 239.38 WHERE productId = 15038;UPDATE product SET overAllAveragePrice = 492.14 WHERE productId = 15411;UPDATE product SET overAllAveragePrice = 236.36 WHERE productId = 15635;UPDATE product SET overAllAveragePrice = 550 WHERE productId = 16282;UPDATE product SET overAllAveragePrice = 550 WHERE productId = 16373;UPDATE product SET overAllAveragePrice = 500 WHERE productId = 16395;UPDATE product SET overAllAveragePrice = 680 WHERE productId = 16425;UPDATE product SET overAllAveragePrice = 360 WHERE productId = 16426;;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:10:33";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:40:33", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:40:33', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=editprint&id=14079');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:10:43";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:40:43", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-12 17:40:43', '77', 'showbarcodebuybill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14079&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:11:47";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:41:47", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-12 17:41:47', '77', 'showbarcodebuybill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcodebuybill&buybillid=14079&type=2');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:11:49";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:41:49", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('productController.php', '2024-12-12 17:41:49', '77', 'showbarcode', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/productController.php?do=showbarcode');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:11:57";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:41:57", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-12 17:41:57', '77', '', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:12:10";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:42:10", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-12 17:42:10', '77', '', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:12:21";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:42:21", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-12 17:42:21', '77', 'show', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:12:31";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:42:31", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:42: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 0675b01a6403f9
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7630,@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-12 17:30:46', '0675b01a6403f9', '7630', '0.00', '232', '0', '1', '232.00', '232', '0', '232', '1', '2024-12-12 17:42:31', '', '101', '0', 'اسماء محمد الجوهري g400', '2', '1', '3', '88', 'اسماء محمد الجوهري g400', '3' ,'0','','','','','-1','0','0','0','0','0','232','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '232', userid = '101' WHERE clientid = '7630';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7630','0.00','232','0','اضافة فاتورة مبيعات','149189', '232', '2024-12-12 17:42:31', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '232', '0', null, '0', null, null,'', '0','1','1','232','1','2024-12-12 17:30:46','0','0');
UPDATE client SET  inUse = 0 where clientid = 7630;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35400;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07048', '149189', '5', '16044', '1', '210', '210', '0', '', '1', '2024-12-12 17:42:31', '16044', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35400-1,','1','1','0','0','210','210','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 351.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 351.00
        , lastbuyprice_withTax = 165, meanbuyprice_withTax = 243, lastbuyprice_withDiscountAndTax = 165
                where sellbilldetailid = 545159;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16044, '2024-12-12', 210, 165, 165
                    , 351, 165, 351, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 165, 243, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+351
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+351
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+243
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 210, 165, 165
                    , 351, 165, 351, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 165, 243, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+210, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+351
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+351
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+243
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 17:42:31' WHERE storedetailid = '16043';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16044', '1', '1', '1', '149189', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '101', '2024-12-12 17:42:31','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149189', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 17:42: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', '149189', '17', '10291', '1', '2', '2', '0', '', '1', '2024-12-12 17:42:31', '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 = 88 where clientid = 7630;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 232, 165, 165
                    , 351, 165, 351, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,165, 243, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+232, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+351
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+351
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+243
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7630, '2024-12-12', 232, 165, 165
                    , 351, 165, 351, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,165, 243, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+232, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+351
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+351
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+165
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+243
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 232, 165, 165
                    , 351, 165, 351, 165, 165, 243)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+232, netSellCostBuyPrice = netSellCostBuyPrice+165
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+165
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+351
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+165
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+351
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+165
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+165
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+243;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b01a6403f9 and sellbillId = 149189 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:12:32";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:42:32", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:42:32', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:12:38";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:42:38", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:42:38', '77', 'details', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=details&id=14067');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:12:59";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:42:59", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-12 17:42:59', '77', '', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:13:06";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:43:06", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-12 17:43:06', '77', 'show', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:13:23";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:43:23", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:43:23', '77', 'details', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=details&id=13997');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:13:28";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 17:43:28", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:43:28', '101', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:13:52";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:43:52", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-12 17:43:52', '77', '', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:14:02";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:44:02", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-12 17:44:02', '77', 'show', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:14:05";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 17:44:05", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:44:05', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149189');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:14:16";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:44:16", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:44:16', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245888
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9583,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '103' , clientdate = '2024-12-12 17:44:17', userid = '2' WHERE clientid = '9583';
UPDATE client SET  inUse = 0 where clientid = 9583;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('9583','1348.00','1245','1','ايصال تحصيل (( قبض من عميل ))','245888', '103', '2024-12-12 17:25:26', '2', 'clientPayedDeptController.php', '   ', '1245', '0', null, '0', null, null,'', '-1','1','1','1245','1','','3165','0');
UPDATE save SET  savecurrentvalue = '498126.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('496881.50','1245', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245893', '498126.5', '2024-12-12 17:44:17', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1245', '1245', '2024-12-12', '2', '0', '0', '2024-12-12 17:44:17','اضافة ايصال سداد للعميل هبه مجدي 13','1','0','0','0','245893','clientPayedDeptController.php?do=show&id=245893');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121748', '-1', '1245', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1245', 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 ('121748', '-1', '1245', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-1245', 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 = '9583', clientdebtchangebefore = '1348.000', clientdebtchangeamount = '1245.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245888', clientdebtchangeafter = '103.000', clientdebtchangedate = '2024-12-12 17:25:26', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1245.00',discount='', reciptid='0', dailyentryid = '121748',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1245',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245893';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245888 -clientdebtchangeId = 245893
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:14:18";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:44:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:44:18', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:14:19";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:44:19", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:44:19', '77', 'details', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=details&id=14020');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:14:23";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:44:23", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storereportController.php', '2024-12-12 17:44:23', '77', '', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storereportController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:14:34";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:44:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:44:35', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245894
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10541,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-4' , clientdate = '2024-12-12 17:44:35', userid = '2' WHERE clientid = '10541';
UPDATE client SET  inUse = 0 where clientid = 10541;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10541','1386.00','1390','1','ايصال تحصيل (( قبض من عميل ))','245894', '-4', '2024-12-12 17:44:18', '2', 'clientPayedDeptController.php', '   ', '1390', '0', null, '0', null, null,'', '-1','1','1','1390','1','','3166','0');
UPDATE save SET  savecurrentvalue = '499516.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('498126.50','1390', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245894', '499516.5', '2024-12-12 17:44:35', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '1390', '1390', '2024-12-12', '2', '0', '0', '2024-12-12 17:44:35','اضافة ايصال سداد للعميل افتكسات بنات 100','1','0','0','0','245894','clientPayedDeptController.php?do=show&id=245894');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121749', '-1', '1390', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '1390', 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 ('121749', '12083', '1390', '','0');
UPDATE accountstree SET name = 'افتكسات بنات 100', customName = 'افتكسات بنات 100', customNameEn = 'افتكسات بنات 100', nameEn = 'افتكسات بنات 100', parent = '58', accountNature = '0', theValue = '-2050', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-11-30 19:04:38' WHERE id = '12083';
UPDATE clientdebtchange SET clientid = '10541', clientdebtchangebefore = '1386.000', clientdebtchangeamount = '1390.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245894', clientdebtchangeafter = '-4.000', clientdebtchangedate = '2024-12-12 17:44:18', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1390.00',discount='', reciptid='0', dailyentryid = '121749',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1390',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245894';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:14:35";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:44:35", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:44:35', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:16:07";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:46:07", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:46:07', '77', 'bill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:16:25";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:46:25", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:46:25', '77', 'add', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('0675b053fd491b', '2024-12-12 17:46:07', '102', '238810.00', '233860', '0', '0', '-4950', '-4950', '0', '-4950', '1', '2024-12-12 17:46:25', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07110', '2496', '5', '16126', '10', '495', '4950', '0', '', '16126','','','0','0','0','0','0','495','4950','0','0','0','0','0','0','0');
UPDATE product SET productName = '7110', productDescription = '', productCatId = '5', productBuyPrice = '495.00', productSellAllPrice = '560.00', productSellUnitPrice = '560.00', productSellHalfPrice = '560.00', productDate = '2024-11-26', conditions = '0', userId = '77', limitamount = '1', parcode = '07110',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '495',lastbuyprice_withDiscount = '495',meanbuyprice = '495',meanbuyprice_withDiscount = '495' , productbuypricereal = '495.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='495',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='495',meanbuyprice_withTax='495',price4='0',price5='0',price6='0',price7='0',price8='0',clientid='0',grantduration='0',onlinepro='0',minappearonline='0',selladdpercent='0',selldiscountpercent='0',buydiscountpercent='0',onlinecatid='0',sellpercenttype='0',searchfiltersid='',lastbuyprice_withDiscountAndTax='495'  WHERE productId = '16126';
UPDATE returnbuybilldetail SET  lastbuyprice = 495 , meanbuyprice = 495, lastbuyprice_withDiscount = 495, meanbuyprice_withDiscount = 495
        , lastbuyprice_withTax = 495, meanbuyprice_withTax = 495, lastbuyprice_withDiscountAndTax = 495
                where returnbuybilldetailid = 3909;
UPDATE productunit SET proUnitBuyPrice  = 495 * productnumber WHERE productid = 16126;
UPDATE storedetail SET  productquantity = '28', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16125';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16126', '1', '10', '1', '2496', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '38', '28', '77', '2024-12-12 17:46:07','0','0');
UPDATE supplier SET  suppliercurrentDebt = '233860',suppliercurrentDebtInCurrency= '233860' , userid = '77', supplierdate = '2024-12-12 17:46:25'   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', '238810.00', '4950', '1', 'اضافة فاتورة مردوات مشتريات', '2496', '233860', '2024-12-12 17:46:07', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','4950','1','238810','4950','233860','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2496;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:16:25";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:46:25", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-12 17:46:25', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2496');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:16:36";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:46:36", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:46:36', '77', 'bill', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=bill&billnameid=6');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:17:05";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:47:06", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 17:47:06', '77', 'add', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=add');
BEGIN;
INSERT INTO returnbuybill (returnbuybillSerial, returnbuybilldate, returnbuybillsupplierid, returnbuybilltotaldeptbefor, returnbuybilltotaldeptafter, returnbuybilldiscount, returnbuybilldiscountrype, returnbuybilltotalbill, returnbuybillaftertotalbill, returnbuybilltotalpayed, returnbuybillfinalbill, returnbuybillstoreid, returnbuybillsysdate,comment, userid, conditions, returnbuybillclientname, returnbuybillsaveid, billnameid, returnbuybilldirectpayment,payedtax,costcenterid,delbyuserid,currencyId,taxOfDiscountPer,taxOfDiscountVal,client) VALUES ('0675b055c91abc', '2024-12-12 17:46:36', '102', '233860.00', '224035', '0', '0', '-9825', '-9825', '0', '-9825', '1', '2024-12-12 17:47:06', '', '77', '0', '', '1', '6','1','0.00','-1','0','1','0','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07266', '2497', '5', '16376', '15', '155', '2325', '0', '', '16376','','','0','0','0','0','0','155','2325','0','0','0','0','0','0','0');
UPDATE product SET productName = '7266', productDescription = '', productCatId = '5', productBuyPrice = '155.00', productSellAllPrice = '210.00', productSellUnitPrice = '210.00', productSellHalfPrice = '210.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07266',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '155',lastbuyprice_withDiscount = '155',meanbuyprice = '155.00',meanbuyprice_withDiscount = '155' , productbuypricereal = '155.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',overAllAveragePrice='155',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='155',meanbuyprice_withTax='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='155'  WHERE productId = '16376';
UPDATE returnbuybilldetail SET  lastbuyprice = 155 , meanbuyprice = 155.00, lastbuyprice_withDiscount = 155, meanbuyprice_withDiscount = 155.00
        , lastbuyprice_withTax = 155, lastbuyprice_withDiscountAndTax = 155
                where returnbuybilldetailid = 3910;
UPDATE productunit SET proUnitBuyPrice  = 155 * productnumber WHERE productid = 16376;
UPDATE storedetail SET  productquantity = '0', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16375';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16376', '1', '15', '1', '2497', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '15', '0', '77', '2024-12-12 17:46:36','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('H1615', '2497', '14', '16306', '15', '365', '5475', '0', '', '16306','','','0','0','0','0','0','365','5475','0','0','0','0','0','0','0');
UPDATE product SET productName = 'H1615', productDescription = '', productCatId = '14', productBuyPrice = '365.00', productSellAllPrice = '430.00', productSellUnitPrice = '430.00', productSellHalfPrice = '430.00', productDate = '2024-12-06', conditions = '0', userId = '77', limitamount = '1', parcode = 'H1615',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '365',lastbuyprice_withDiscount = '365',meanbuyprice = '369',meanbuyprice_withDiscount = '369' , 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='367.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='365',meanbuyprice_withTax='372',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 = '16306';
UPDATE returnbuybilldetail SET  lastbuyprice = 365 , meanbuyprice = 369, lastbuyprice_withDiscount = 365, meanbuyprice_withDiscount = 369
        , lastbuyprice_withTax = 365, meanbuyprice_withTax = 372, lastbuyprice_withDiscountAndTax = 365
                where returnbuybilldetailid = 3911;
UPDATE productunit SET proUnitBuyPrice  = 365 * productnumber WHERE productid = 16306;
UPDATE storedetail SET  productquantity = '6', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16305';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16306', '1', '15', '1', '2497', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '21', '6', '77', '2024-12-12 17:46:36','0','0');
INSERT INTO returnbuybilldetail (Parcode, returnbuybillid, returnbuybilldetailcatid, returnbuybilldetailproductid, returnbuybilldetailquantity, returnbuybilldetailprice, returnbuybilldetailtotalprice, discountvalue, note, productunitid,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid, returnbuybilldetailpriceC, returnbuybilldetailtotalpriceC, discountvalueC,discounttype,rowtaxval,rowtaxper,lastbuyprice_withTax,meanbuyprice_withTax,lastbuyprice_withDiscountAndTax) VALUES ('07267', '2497', '5', '16380', '15', '135', '2025', '0', '', '16380','','','0','0','0','0','0','135','2025','0','0','0','0','0','0','0');
UPDATE product SET productName = '7267', productDescription = '', productCatId = '5', productBuyPrice = '135.00', productSellAllPrice = '185.00', productSellUnitPrice = '185.00', productSellHalfPrice = '185.00', productDate = '2024-12-10', conditions = '0', userId = '77', limitamount = '1', parcode = '07267',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '135',lastbuyprice_withDiscount = '135',meanbuyprice = '135.00',meanbuyprice_withDiscount = '135' , productbuypricereal = '135.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='135',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0',weightedDiscount='0',sortby='0',TypeOfBarcodeInTax='',barcodeInTax='',productNameE='',partNumber='0',vehicleType='0',company='0',weight='0',origin='',hscode='0',power='0',ProductionDate='',expiry='0',procode='',lastbuyprice_withTax='135',meanbuyprice_withTax='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='135'  WHERE productId = '16380';
UPDATE returnbuybilldetail SET  lastbuyprice = 135 , meanbuyprice = 135.00, lastbuyprice_withDiscount = 135, meanbuyprice_withDiscount = 135.00
        , lastbuyprice_withTax = 135, lastbuyprice_withDiscountAndTax = 135
                where returnbuybilldetailid = 3912;
UPDATE productunit SET proUnitBuyPrice  = 135 * productnumber WHERE productid = 16380;
UPDATE storedetail SET  productquantity = '0', userid = '77', storedetaildate = '2024-12-12' WHERE storedetailid = '16379';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16380', '1', '15', '1', '2497', 'اضافة فاتورة مردودات مشتريات', 'returnBuyBillController.php', '15', '0', '77', '2024-12-12 17:46:36','0','0');
UPDATE supplier SET  suppliercurrentDebt = '224035',suppliercurrentDebtInCurrency= '224035' , userid = '77', supplierdate = '2024-12-12 17:47:06'   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', '233860.00', '9825', '1', 'اضافة فاتورة مردوات مشتريات', '2497', '224035', '2024-12-12 17:46:36', '77', 'returnBuyBillController.php', 'اضافة فاتورة مردوات مشتريات', '0','', '0','1','1','9825','1','233860','9825','224035','0');
update returnbuybill set dailyentryid='0,' where returnbuybillid=2497;
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:17:06";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 17:47:06", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('returnBuyBillController.php', '2024-12-12 17:47:06', '77', 'editprint', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/returnBuyBillController.php?do=editprint&id=2497');
UPDATE user SET loginip = "" WHERE userid = 77;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:20:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:50:47", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 17:50:47', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:20:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:50:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 17:50: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-12 14:21:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:51:05", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:51:05', '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-12 14:21:48";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:51:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 17:51:48', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:22:04";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:52:04", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-12 17:52:04', '77', 'oneSupplier', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:22:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:52:30", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-12 17:52:30', '77', 'oneSupplier', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:23:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:53:11", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-12 17:53:11', '77', 'all', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=all');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:23:14";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:53:14", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:53:14', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b04689478b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10274,@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-12 17:42:32', '0675b04689478b', '10274', '0.00', '187', '0', '1', '187.00', '187', '0', '187', '1', '2024-12-12 17:53:14', '', '101', '0', 'امل محمد حسين 61', '2', '1', '3', '88', 'امل محمد حسين 61', '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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '187', userid = '101' WHERE clientid = '10274';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10274','0.00','187','0','اضافة فاتورة مبيعات','149190', '187', '2024-12-12 17:53:14', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '187', '0', null, '0', null, null,'', '0','1','1','187','1','2024-12-12 17:42:32','0','0');
UPDATE client SET  inUse = 0 where clientid = 10274;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06102', '149190', '5', '13782', '1', '165', '165', '0', '', '1', '2024-12-12 17:53:14', '13782', '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 = 230.00 , meanbuyprice = 212.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 212.00
        
                where sellbilldetailid = 545162;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13782, '2024-12-12', 165, 230, 230
                    , 212, 230, 212, 206.32
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+212
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+212
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+206.32
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 165, 230, 230
                    , 212, 230, 212, 206.32
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+212
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+212
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+206.32
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 17:53:14' WHERE storedetailid = '13781';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13782', '1', '1', '1', '149190', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '101', '2024-12-12 17:53:14','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149190', '17', '10291', '1', '2', '2', '0', '', '1', '2024-12-12 17:53:14', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','2','2','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149190', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 17:53: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');
UPDATE client SET  delegateid = 88 where clientid = 10274;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 187, 230, 230
                    , 212, 230, 212, 206.32
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+187, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+212
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+212
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+206.32
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10274, '2024-12-12', 187, 230, 230
                    , 212, 230, 212, 206.32
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+187, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+212
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+212
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+206.32
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 230, 230
                    , 212, 230, 212, 206.32, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+187, netSellCostBuyPrice = netSellCostBuyPrice+230
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+230
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+212
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+230
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+212
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+206.32
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b04689478b and sellbillId = 149190 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:23:15";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 17:53:15", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:53:15', '101', 'addsellBill', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:23:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:53:36", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-12 17:53:36', '77', 'oneSupplier', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:23:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:53:49", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-12 17:53:49', '77', 'all', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=all');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:24:02";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 17:54:02", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:54:02', '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-12 14:24:21";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 17:54:21", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:54:21', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149190');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:25:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:55:19", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-12 17:55:19', '77', 'all', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=all');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:25:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:55:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:55: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 0675b03875418f
-- ----------------------------------------------------------------------------------------------------

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-12 17:38:47', '0675b03875418f', '1', '0.00', '0', '0', '1', '1030.00', '1030', '1030', '0', '1', '2024-12-12 17:55:45', '', '104', '0', 'نقدي', '1', '0', '3', '24', 'نقدي', '7' ,'0','','','','','-1','0','0','0','0','0','1030','0','','0','0','1030','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149191', '0', '2024-12-12 17:55:45', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1030', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 17:38:47','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', '149191', '5', '16299', '1', '200', '200', '0', '', '1', '2024-12-12 17:55:45', '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 = 545165;
 INSERT INTO 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-12', 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-12', 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 = '20', userid = '104', storedetaildate = '2024-12-12 17:55:45' WHERE storedetailid = '16298';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16299', '1', '1', '1', '149191', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21', '20', '104', '2024-12-12 17:55:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36119;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149191', '5', '16022', '1', '200', '200', '0', '', '1', '2024-12-12 17:55:45', '16022', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36119-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 = 545166;
 INSERT INTO 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-12', 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-12', 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 = '10', userid = '104', storedetaildate = '2024-12-12 17:55:45' WHERE storedetailid = '16021';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16022', '1', '1', '1', '149191', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '104', '2024-12-12 17:55:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '149191', '5', '16152', '2', '260', '520', '0', '', '1', '2024-12-12 17:55:45', '16152', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35803-2,','1','1','0','0','260','520','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 = 545167;
 INSERT INTO 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-12', 520, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, 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+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-12', 520, 400, 400
                    , 400, 400, 400, 400
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 400, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+520, 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 = '53', userid = '104', storedetaildate = '2024-12-12 17:55:45' WHERE storedetailid = '16151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16152', '1', '2', '1', '149191', 'اضافة فاتورة مبيعات', 'sellbillController.php', '55', '53', '104', '2024-12-12 17:55:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31793;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06290', '149191', '5', '14294', '1', '50', '50', '0', '', '1', '2024-12-12 17:55:45', '14294', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31793-1,','1','1','0','0','50','50','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
        
                where sellbilldetailid = 545168;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14294, '2024-12-12', 50, 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+50, 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-12', 50, 175, 175
                    , 175, 175, 175, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+50, 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 = '0', userid = '104', storedetaildate = '2024-12-12 17:55:45' WHERE storedetailid = '14293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14294', '1', '1', '1', '149191', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-12 17:55:45','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33268;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06551', '149191', '5', '14943', '1', '50', '50', '0', '', '1', '2024-12-12 17:55:45', '14943', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33268-1,','1','1','0','0','50','50','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 708.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 708.00
        
                where sellbilldetailid = 545169;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14943, '2024-12-12', 50, 160, 160
                    , 708, 160, 708, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+50, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+708
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+708
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 50, 160, 160
                    , 708, 160, 708, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+50, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+708
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+708
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+160
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '104', storedetaildate = '2024-12-12 17:55:45' WHERE storedetailid = '14942';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14943', '1', '1', '1', '149191', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-12 17:55: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 ('0','10291', '149191', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-12 17:55:45', '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 = '16870',  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 ('15840','1030', '0', '1', 'اضافة فاتورة مبيعات', '149191', '16870', '2024-12-12 17:55:45', '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-12', 1030, 1015, 1015
                    , 1563, 1015, 1563, 1015
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,680, 680, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1030, sellCostBuyPrice =sellCostBuyPrice+1015
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1015, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1563
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1015, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1563
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1015
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+680
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+680
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 1030, 1015, 1015
                    , 1563, 1015, 1563, 1015
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,680, 680, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1030, sellCostBuyPrice =sellCostBuyPrice+1015
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1015, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1563
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1015, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1563
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1015
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+680
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+680
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1030, 1015, 1015
                    , 1563, 1015, 1563, 1015, 680, 680)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1030, netSellCostBuyPrice = netSellCostBuyPrice+1015
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1015
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1563
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1015
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1563
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1015
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+680
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+680;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b03875418f and sellbillId = 149191 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:25:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:55:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:55: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-12 14:25:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:55:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:55:51', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:25:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:55:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:55:57', '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', '1030', '2024-12-12', '104', '0', '0','','1','1','0','0','1030');
UPDATE save SET  savecurrentvalue = '15840',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('16870.00','1030', '1', '1', 'تحويل امول الى الخزنة  [ فودافون كاش ] ', '3491', '15840', '2024-12-12 17:55:57', '104',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '500546.5',  userid = '104' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('499516.50','1030', '0', '2', 'تحويل امول من الخزنة  [ نقدي ] ', '3491', '500546.5', '2024-12-12 17:55:57', '104',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '2', transfermoneyvalue = '1030.00', transfermoneydate = '2024-12-12', userid = '104', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='1030' WHERE transfermoneyid = '3491';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:25:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:55:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:55:57', '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-12 14:25:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:55:59", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 17:55:59', '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-12 14:27:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:57:48", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-12 17:57:48', '77', 'oneSupplier', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:28:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 17:58:01", deviceType = "DESKTOP" WHERE userid = 77;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('supplierReportsController.php', '2024-12-12 17:58:01', '77', 'oneSupplier', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/supplierReportsController.php?do=oneSupplier');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:28:18";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:58:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:58:18', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245895
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10293,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '3' , clientdate = '2024-12-12 17:58:18', userid = '2' WHERE clientid = '10293';
UPDATE client SET  inUse = 0 where clientid = 10293;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10293','683.00','680','1','ايصال تحصيل (( قبض من عميل ))','245895', '3', '2024-12-12 17:44:35', '2', 'clientPayedDeptController.php', '   ', '680', '0', null, '0', null, null,'', '-1','1','1','680','1','','3167','0');
UPDATE save SET  savecurrentvalue = '501226.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('500546.50','680', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245897', '501226.5', '2024-12-12 17:58:18', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '680', '680', '2024-12-12', '2', '0', '0', '2024-12-12 17:58:18','اضافة ايصال سداد للعميل رنا ديروط ','1','0','0','0','245897','clientPayedDeptController.php?do=show&id=245897');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121750', '-1', '680', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '680', 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 ('121750', '11259', '680', '','0');
UPDATE accountstree SET name = 'رنا ديروط ', customName = 'رنا ديروط ', customNameEn = 'رنا ديروط ', nameEn = 'رنا ديروط ', parent = '58', accountNature = '0', theValue = '-2765', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '75', del = '0', sysdate = '2024-11-06 13:40:22' WHERE id = '11259';
UPDATE clientdebtchange SET clientid = '10293', clientdebtchangebefore = '683.000', clientdebtchangeamount = '680.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245895', clientdebtchangeafter = '3.000', clientdebtchangedate = '2024-12-12 17:44:35', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '680.00',discount='', reciptid='0', dailyentryid = '121750',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='680',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245897';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245895 -clientdebtchangeId = 245897
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245898
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:28:44";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 17:58:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 17:58:44', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:28:54";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 17:58:54", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 17:58:54', '2', 'addsellBill', '192.168.1.59', '', '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 ('ايمان رمضان 99' , '', '', '011288237515', '0', '', '0', '2024-12-12 17:59:18', '2', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-12','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10684', '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 ('10684','0','0','0','إضافة عميل جديد','10684', '0', '2024-12-12 17:59:18', '2', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('ايمان رمضان 99', 'ايمان رمضان 99', 'ايمان رمضان 99', 'ايمان رمضان 99', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '2', '0', '2024-12-12 17:59:18');
UPDATE client SET clientname = 'ايمان رمضان 99', clientaddress = '', clientphone = '', clientmobile = '011288237515', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-12', userid = '2'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12425',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10684';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:29:37";
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-12 14:29:44";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 17:59:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 17:59:44', '2', '', '192.168.1.59', '', '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-12 14:29:45";
UPDATE user SET loginip = "" WHERE userid = 101;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:29:48";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 17:59:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 17:59:48', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.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-12 14:30:00";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:00:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 18:00:00', '2', '', '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-12 14:30:01";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:30:04";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:00:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 18:00:04', '2', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:30:07";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:00:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 18:00:07', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245899
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245899 -clientdebtchangeId = 245900
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:30:08";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:00:08", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 18:00:08', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:30:23";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:00:23", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 18:00:23', '2', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE userid = 77;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:32:28";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:02:28", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 18:02:28', '2', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:32:36";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:02:36", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 18:02:36', '2', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:32:57";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:02:57", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 18:02:57', '2', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:35:20";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:05:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:05:20', '2', '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-12 14:35:31";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:05:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 18:05:31', '2', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:35:35";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:05:35", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 18:05:35', '2', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:35:46";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:05:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 18:05:46', '2', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:35:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:05:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:05: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 0675b0669bc757
-- ----------------------------------------------------------------------------------------------------

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-12 17:51:05', '0675b0669bc757', '1', '0.00', '0', '120', '1', '2980.00', '2860', '2860', '0', '1', '2024-12-12 18:05:55', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '8' ,'0','','','','','-1','0','0','0','0','0','2860','0','','0','0','2860','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149192', '0', '2024-12-12 18:05:55', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2860', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 17:51:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35982;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('355','07234', '149192', '5', '16327', '1', '400', '400', '0', '', '1', '2024-12-12 18:05:55', '16327', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35982-1,','1','1','0','0','400','400','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 359.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 359.00
        , lastbuyprice_withTax = 360, meanbuyprice_withTax = 358, lastbuyprice_withDiscountAndTax = 360
                where sellbilldetailid = 545171;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16327, '2024-12-12', 383.89261744966, 360, 360
                    , 359, 360, 359, 357.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 358, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+383.89261744966, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+359
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+359
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+357.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+358
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 383.89261744966, 360, 360
                    , 359, 360, 359, 357.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 358, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+383.89261744966, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+359
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+359
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+357.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+358
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '25', userid = '104', storedetaildate = '2024-12-12 18:05:55' WHERE storedetailid = '16326';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16327', '1', '1', '1', '149192', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '104', '2024-12-12 18:05:55','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35893;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('270','R3325', '149192', '1', '16290', '1', '350', '350', '0', '', '1', '2024-12-12 18:05:55', '16290', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35893-1,','1','1','0','0','350','350','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 270.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 270.00, meanbuyprice_withDiscount = 270.00
        , lastbuyprice_withTax = 270, meanbuyprice_withTax = 270, lastbuyprice_withDiscountAndTax = 270
                where sellbilldetailid = 545172;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16290, '2024-12-12', 335.90604026846, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 270, 270, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+335.90604026846, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+270
                            , 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-12', 335.90604026846, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 270, 270, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+335.90604026846, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+270
                            , 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 = '9', userid = '104', storedetaildate = '2024-12-12 18:05:55' WHERE storedetailid = '16289';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16290', '1', '1', '1', '149192', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-12 18:05:55','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', '149192', '5', '16053', '1', '450', '450', '0', '', '1', '2024-12-12 18:05:55', '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 = 545173;
 INSERT INTO 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-12', 431.87919463087, 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+431.87919463087, 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-12', 431.87919463087, 375, 375
                    , 375, 375, 375, 375
                    , 0, 0, 0, 0
                    , 0, 0, 0, 375, 375, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+431.87919463087, 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 = '16', userid = '104', storedetaildate = '2024-12-12 18:05:55' WHERE storedetailid = '16052';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16053', '1', '1', '1', '149192', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '104', '2024-12-12 18:05:55','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35401;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07000', '149192', '5', '15950', '1', '210', '210', '0', '', '1', '2024-12-12 18:05:55', '15950', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35401-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 = 545174;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15950, '2024-12-12', 201.54362416107, 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+201.54362416107, 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-12', 201.54362416107, 155, 155
                    , 155, 155, 155, 155
                    , 0, 0, 0, 0
                    , 0, 0, 0, 155, 155, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+201.54362416107, 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 = '104', storedetaildate = '2024-12-12 18:05:55' WHERE storedetailid = '15949';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15950', '1', '1', '1', '149192', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-12 18:05:55','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', '149192', '5', '16152', '1', '250', '250', '0', '', '1', '2024-12-12 18:05:56', '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 = 545175;
 INSERT INTO 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-12', 239.93288590604, 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+239.93288590604, 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-12', 239.93288590604, 200, 200
                    , 200, 200, 200, 200
                    , 0, 0, 0, 0
                    , 0, 0, 0, 200, 200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+239.93288590604, 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 = '52', userid = '104', storedetaildate = '2024-12-12 18:05:56' WHERE storedetailid = '16151';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16152', '1', '1', '1', '149192', 'اضافة فاتورة مبيعات', 'sellbillController.php', '53', '52', '104', '2024-12-12 18:05:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34801;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3203', '149192', '1', '15391', '1', '310', '310', '0', '', '1', '2024-12-12 18:05:56', '15391', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34801-1,','1','1','0','0','310','310','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 259.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 259.00
        , lastbuyprice_withTax = 260, meanbuyprice_withTax = 220, lastbuyprice_withDiscountAndTax = 260
                where sellbilldetailid = 545176;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15391, '2024-12-12', 297.51677852349, 260, 260
                    , 259, 260, 259, 256.82
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 260, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+297.51677852349, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+259
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+259
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+256.82
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , 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-12', 297.51677852349, 260, 260
                    , 259, 260, 259, 256.82
                    , 0, 0, 0, 0
                    , 0, 0, 0, 260, 220, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+297.51677852349, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+259
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+259
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+256.82
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+260
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+220
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '18', userid = '104', storedetaildate = '2024-12-12 18:05:56' WHERE storedetailid = '15390';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15391', '1', '1', '1', '149192', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19', '18', '104', '2024-12-12 18:05:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35866;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('145','07191', '149192', '5', '16271', '1', '200', '200', '0', '', '1', '2024-12-12 18:05:56', '16271', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35866-1,','1','1','0','0','200','200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 145.00 , meanbuyprice = 145.00, lastbuyprice_withDiscount = 145.00, meanbuyprice_withDiscount = 145.00
        , lastbuyprice_withTax = 145, meanbuyprice_withTax = 145
                where sellbilldetailid = 545177;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16271, '2024-12-12', 191.94630872483, 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+191.94630872483, 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-12', 191.94630872483, 145, 145
                    , 145, 145, 145, 145
                    , 0, 0, 0, 0
                    , 0, 0, 0, 145, 145, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+191.94630872483, 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 = '104', storedetaildate = '2024-12-12 18:05:56' WHERE storedetailid = '16270';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16271', '1', '1', '1', '149192', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '104', '2024-12-12 18:05:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35878;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149192', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-12 18:05:56', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35878-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 = 545178;
 INSERT INTO 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-12', 777.38255033557, 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+777.38255033557, 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-12', 777.38255033557, 730, 730
                    , 730, 730, 730, 730
                    , 0, 0, 0, 0
                    , 0, 0, 0, 730, 730, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+777.38255033557, 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 = '68', userid = '104', storedetaildate = '2024-12-12 18:05:56' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '149192', 'اضافة فاتورة مبيعات', 'sellbillController.php', '69', '68', '104', '2024-12-12 18:05:56','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '18700',  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 ('15840','2860', '0', '1', 'اضافة فاتورة مبيعات', '149192', '18700', '2024-12-12 18:05:56', '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-12', 2860, 2495, 2495
                    , 2493, 2495, 2493, 2489.32
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2495, 2453, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2860, sellCostBuyPrice =sellCostBuyPrice+2495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2493
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2493
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2489.32
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2453
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 2860, 2495, 2495
                    , 2493, 2495, 2493, 2489.32
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2495, 2453, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2860, sellCostBuyPrice =sellCostBuyPrice+2495
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2495, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2493
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2495, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2493
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2489.32
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2495
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2453
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 2860, 2495, 2495
                    , 2493, 2495, 2493, 2489.32, 2495, 2453)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2860, netSellCostBuyPrice = netSellCostBuyPrice+2495
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2495
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2493
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2495
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2493
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2489.32
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2495
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2453;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b0669bc757 and sellbillId = 149192 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:35:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:05:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:05: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-12 14:36:04";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:06:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 18:06:04', '2', '', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:36:27";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:06:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:06:27', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:36:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:06:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:06:38', '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', 'نسبه ', '', '1800', '2024-12-12', '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 = '16900',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('18700.00','1800', '1', '1', 'إضافة مصروف', '25620', '16900', '2024-12-12 18:06:38', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'نسبه ', expensesdetails = '', expensesValue = '1800.00', expensesdate = '2024-12-12', 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 = '25620';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:36:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:06:39", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:06: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-12 14:36:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:06:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:06: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-12 14:36:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:06:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:06: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-12 14:36:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:06:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:06: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-12 14:36:58";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:06:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 18:06:58', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245901
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245901 -clientdebtchangeId = 245902
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245903
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245904
-- ----------------------------------------------------------------------------------------------------

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

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =9409
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9409,@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 ('9409','100.00','100','1','تسوية عجز عميل بالخصم','-1', '0', '2024-12-12 18:08:16', '2', 'clientDeficitController.php', '', '100', '0', null, '0', null, null,'', '0','1','1','100','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12', userid = '2' WHERE clientid = '9409';
UPDATE client SET  inUse = 0 where clientid = 9409;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =9409 ,id=245905
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:38:17";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:08:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 18:08:17', '2', 'sucess', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:38:19";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:08:19", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 18:08:19', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:38:23";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:08:23", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 18:08:23', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:38:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:08:45", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:08: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-12 14:38:54";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:08:54", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 18:08:54', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =9583
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(9583,@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 ('9583','103.00','103','1','تسوية عجز عميل بالخصم','-1', '0', '2024-12-12 18:08:54', '2', 'clientDeficitController.php', '', '103', '0', null, '0', null, null,'', '0','1','1','103','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12', userid = '2' WHERE clientid = '9583';
UPDATE client SET  inUse = 0 where clientid = 9583;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =9583 ,id=245906
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:38:55";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:08:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 18:08:55', '2', 'sucess', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:38:57";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:08:57", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 18:08:57', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:39:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:09:49", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:09:49', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b0a8d6c7c7
-- ----------------------------------------------------------------------------------------------------

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-12 18:08:45', '0675b0a8d6c7c7', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-12 18:09:49', '', '104', '0', 'نقدي', '1', '0', '3', '54', 'نقدي', '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-12','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','اضافة فاتورة مبيعات','149193', '0', '2024-12-12 18:09:49', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 18:08:45','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', '149193', '14', '16208', '1', '300', '300', '0', '', '1', '2024-12-12 18:09:49', '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 = 545179;
 INSERT INTO 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-12', 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-12', 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 = '19', userid = '104', storedetaildate = '2024-12-12 18:09: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', '149193', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '104', '2024-12-12 18:09:49','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '17200',  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 ('16900','300', '0', '1', 'اضافة فاتورة مبيعات', '149193', '17200', '2024-12-12 18:09:49', '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-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 300, 240, 240
                    , 240, 240, 240, 240, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, 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 0675b0a8d6c7c7 and sellbillId = 149193 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245905
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5754,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '2' , clientdate = '2024-12-12 18:11:38', userid = '2' WHERE clientid = '5754';
UPDATE client SET  inUse = 0 where clientid = 5754;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5754','1042.00','1040','1','ايصال تحصيل (( قبض من عميل ))','245905', '2', '2024-12-12 18:07:46', '2', 'clientPayedDeptController.php', '   ', '1040', '0', null, '0', null, null,'', '-1','1','1','1040','1','','3173','0');
UPDATE save SET  savecurrentvalue = '505751.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('504711.50','1040', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245908', '505751.5', '2024-12-12 18:11:38', '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-12', '2', '0', '0', '2024-12-12 18:11:38','اضافة ايصال سداد للعميل ايمان كمال السعدي U500','1','0','0','0','245908','clientPayedDeptController.php?do=show&id=245908');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121756', '-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 ('121756', '-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 = '5754', clientdebtchangebefore = '1042.000', clientdebtchangeamount = '1040.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245905', clientdebtchangeafter = '2.000', clientdebtchangedate = '2024-12-12 18:07:46', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1040.00',discount='', reciptid='0', dailyentryid = '121756',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1040',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245908';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245905 -clientdebtchangeId = 245908
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:41:38";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:11:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 18:11:39', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:42:00";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:12:00", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:12: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 0675b0ace8d6f3
-- ----------------------------------------------------------------------------------------------------

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-12 18:09:50', '0675b0ace8d6f3', '1', '0.00', '0', '0', '1', '1240.00', '1240', '1240', '0', '1', '2024-12-12 18:12:00', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','1240','0','','0','0','1240','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149194', '0', '2024-12-12 18:12:00', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1240', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 18:09:50','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', '149194', '14', '16388', '1', '670', '670', '0', '', '1', '2024-12-12 18:12:00', '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 = 545180;
 INSERT INTO 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-12', 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-12', 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 = '27', userid = '104', storedetaildate = '2024-12-12 18:12:00' WHERE storedetailid = '16387';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16388', '1', '1', '1', '149194', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28', '27', '104', '2024-12-12 18:12:00','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', '149194', '14', '15689', '1', '570', '570', '0', '', '1', '2024-12-12 18:12:00', '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 = 545181;
 INSERT INTO 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-12', 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-12', 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 = '17', userid = '104', storedetaildate = '2024-12-12 18:12:00' WHERE storedetailid = '15688';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15689', '1', '1', '1', '149194', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '104', '2024-12-12 18:12:00','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '18440',  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 ('17200','1240', '0', '1', 'اضافة فاتورة مبيعات', '149194', '18440', '2024-12-12 18:12:01', '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-12', 1240, 1075, 1075
                    , 1075, 1075, 1075, 1075
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1075, 1075, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1240, sellCostBuyPrice =sellCostBuyPrice+1075
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1075, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1075
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1075, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1075
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1075
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1075
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1075
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 1240, 1075, 1075
                    , 1075, 1075, 1075, 1075
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1075, 1075, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1240, sellCostBuyPrice =sellCostBuyPrice+1075
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1075, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1075
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1075, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1075
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1075
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1075
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1075
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1240, 1075, 1075
                    , 1075, 1075, 1075, 1075, 1075, 1075)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1240, netSellCostBuyPrice = netSellCostBuyPrice+1075
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1075
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1075
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1075
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1075
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1075
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1075
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1075;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b0ace8d6f3 and sellbillId = 149194 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:42:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:12:01", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:12: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-12 14:42:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:12:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:12: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 0675b0b51b5193
-- ----------------------------------------------------------------------------------------------------

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-12 18:12:01', '0675b0b51b5193', '1', '0.00', '0', '0', '1', '530.00', '530', '530', '0', '1', '2024-12-12 18:12:55', '', '104', '0', 'نقدي', '1', '0', '3', '24', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','530','0','','0','0','530','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149195', '0', '2024-12-12 18:12:55', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '530', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 18:12:01','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34741;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06917', '149195', '5', '15768', '1', '530', '530', '0', '', '1', '2024-12-12 18:12:55', '15768', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34741-1,','1','1','0','0','530','530','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
        , lastbuyprice_withTax = 475, meanbuyprice_withTax = 475, lastbuyprice_withDiscountAndTax = 475
                where sellbilldetailid = 545182;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15768, '2024-12-12', 530, 475, 475
                    , 475, 475, 475, 475
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 475, 475, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, 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
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 530, 475, 475
                    , 475, 475, 475, 475
                    , 0, 0, 0, 0
                    , 0, 0, 0, 475, 475, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, 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;
UPDATE storedetail SET  productquantity = '42', userid = '104', storedetaildate = '2024-12-12 18:12:55' WHERE storedetailid = '15767';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15768', '1', '1', '1', '149195', 'اضافة فاتورة مبيعات', 'sellbillController.php', '43', '42', '104', '2024-12-12 18:12:55','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '18970',  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 ('18440','530', '0', '1', 'اضافة فاتورة مبيعات', '149195', '18970', '2024-12-12 18:12:55', '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-12', 530, 475, 475
                    , 475, 475, 475, 475
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,475, 475, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, 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-12', 530, 475, 475
                    , 475, 475, 475, 475
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,475, 475, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, 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, 530, 475, 475
                    , 475, 475, 475, 475, 475, 475)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+530, 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 0675b0b51b5193 and sellbillId = 149195 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245909
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245909 -clientdebtchangeId = 245911
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:43:15";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:13:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 18:13:15', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:43:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:13:17", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:13: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-12 14:43:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:13:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:13:38', '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-12', '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 = '18920',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('18970.00','50', '1', '1', 'إضافة مصروف', '25621', '18920', '2024-12-12 18:13:38', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كيمو', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25621';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:43:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:13:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:13: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-12 14:43:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:13:40", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:13:40', '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-12 14:43:44";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:13:44", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:13:44', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:43:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:13:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:13: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', 'كيمو', '', '5', '2024-12-12', '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 = '18915',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('18920.00','5', '1', '1', 'إضافة مصروف', '25622', '18915', '2024-12-12 18:13:54', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كيمو', expensesdetails = '', expensesValue = '5.00', expensesdate = '2024-12-12', 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 = '25622';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:43:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:13:55", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:13:55', '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-12 14:43:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:13:57", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:13:57', '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-12 14:46:17";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:16:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 18:16:17', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245912
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:46:17";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:16:17", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 18:16:17', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:46:19";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:16:19", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:16:19', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:46:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:16:22", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:16:22', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b0a1311df1
-- ----------------------------------------------------------------------------------------------------

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-12 18:06:43', '0675b0a1311df1', '1', '0.00', '0', '0', '1', '1300.00', '1300', '1300', '0', '1', '2024-12-12 18:16:22', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '10' ,'0','','','','','-1','0','0','0','0','0','1300','0','','0','0','1300','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149196', '0', '2024-12-12 18:16:22', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 18:06:43','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 28095;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2574', '149196', '1', '12513', '1', '120', '120', '0', '', '1', '2024-12-12 18:16:22', '12513', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','28095-1,','1','1','0','0','120','120','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 = 545183;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12513, '2024-12-12', 120, 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+120, 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-12', 120, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '1', userid = '104', storedetaildate = '2024-12-12 18:16:22' WHERE storedetailid = '12512';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12513', '1', '1', '1', '149196', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2', '1', '104', '2024-12-12 18:16:22','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29144;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2423', '149196', '1', '11782', '1', '120', '120', '0', '', '1', '2024-12-12 18:16:22', '11782', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29144-1,','1','1','0','0','120','120','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 245.00 , meanbuyprice = 244.00, lastbuyprice_withDiscount = 245.00, meanbuyprice_withDiscount = 244.00
        
                where sellbilldetailid = 545184;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11782, '2024-12-12', 120, 245, 245
                    , 244, 245, 244, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+244
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+244
                            , 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-12', 120, 245, 245
                    , 244, 245, 244, 265
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+245
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+245, sellCostMeanBuyPrice = sellCostMeanBuyPrice+244
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+245, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+244
                            , 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 = '-1', userid = '104', storedetaildate = '2024-12-12 18:16:22' WHERE storedetailid = '11781';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11782', '1', '1', '1', '149196', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0', '-1', '104', '2024-12-12 18:16:22','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 29580;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2695', '149196', '1', '13232', '1', '120', '120', '0', '', '1', '2024-12-12 18:16:22', '13232', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','29580-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 = 545185;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13232, '2024-12-12', 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-12', 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 = '2', userid = '104', storedetaildate = '2024-12-12 18:16:22' WHERE storedetailid = '13231';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13232', '1', '1', '1', '149196', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '104', '2024-12-12 18:16: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 ('260','R2698', '149196', '1', '13251', '1', '90', '90', '0', '', '1', '2024-12-12 18:16:22', '13251', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','90','90','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 260.00
        
                where sellbilldetailid = 545186;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13251, '2024-12-12', 90, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+90, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 90, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+90, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+260
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '0', userid = '104', storedetaildate = '2024-12-12 18:16:22' WHERE storedetailid = '13250';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13251', '1', '1', '1', '149196', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-12 18:16: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 ('245','R2786', '149196', '1', '13845', '1', '120', '120', '0', '', '1', '2024-12-12 18:16:22', '13845', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','120','120','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 245.00 , meanbuyprice = 245.00, lastbuyprice_withDiscount = 245.00, meanbuyprice_withDiscount = 245.00
        
                where sellbilldetailid = 545187;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13845, '2024-12-12', 120, 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+120, 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-12', 120, 245, 245
                    , 245, 245, 245, 245
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, 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 = '0', userid = '104', storedetaildate = '2024-12-12 18:16:22' WHERE storedetailid = '13844';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13845', '1', '1', '1', '149196', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-12 18:16: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 ('230','0B813', '149196', '2', '11967', '1', '100', '100', '0', '', '1', '2024-12-12 18:16:22', '11967', '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 = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        
                where sellbilldetailid = 545188;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11967, '2024-12-12', 100, 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+100, 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-12', 100, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+100, 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-12 18:16:22' WHERE storedetailid = '11966';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11967', '1', '1', '1', '149196', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-12 18:16: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 ('50','000M1', '149196', '1', '4724', '1', '130', '130', '0', '', '1', '2024-12-12 18:16:22', '4724', '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 = 50.00 , meanbuyprice = 50.00, lastbuyprice_withDiscount = 50.00, meanbuyprice_withDiscount = 50.00
        
                where sellbilldetailid = 545189;
 INSERT INTO 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-12', 130, 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+130, 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-12', 130, 50, 50
                    , 50, 50, 50, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+130, 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 = '-135', userid = '104', storedetaildate = '2024-12-12 18:16:22' WHERE storedetailid = '4723';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('4724', '1', '1', '1', '149196', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-134', '-135', '104', '2024-12-12 18:16: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 ('230','R2505', '149196', '1', '12173', '1', '80', '80', '0', '', '1', '2024-12-12 18:16:22', '12173', '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 = 230.00 , meanbuyprice = 345.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 345.00
        
                where sellbilldetailid = 545190;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (12173, '2024-12-12', 80, 230, 230
                    , 345, 230, 345, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+80, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 80, 230, 230
                    , 345, 230, 345, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+80, sellCostBuyPrice =sellCostBuyPrice+230
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+230
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-3', userid = '104', storedetaildate = '2024-12-12 18:16:22' WHERE storedetailid = '12172';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('12173', '1', '1', '1', '149196', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-2', '-3', '104', '2024-12-12 18:16:22','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19463;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','0H931', '149196', '14', '9083', '1', '285', '285', '0', '', '1', '2024-12-12 18:16:22', '9083', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','19463-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
        
                where sellbilldetailid = 545191;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9083, '2024-12-12', 285, 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+285, 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-12', 285, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 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+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 18:16:22' WHERE storedetailid = '9082';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9083', '1', '1', '1', '149196', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '104', '2024-12-12 18:16: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 ('230','R2835', '149196', '1', '14157', '1', '135', '135', '0', '', '1', '2024-12-12 18:16:22', '14157', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','135','135','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 230.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 230.00
        
                where sellbilldetailid = 545192;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14157, '2024-12-12', 135, 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+135, 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-12', 135, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+135, 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-12 18:16:22' WHERE storedetailid = '14156';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14157', '1', '1', '1', '149196', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-12 18:16:22','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20215',  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 ('18915','1300', '0', '1', 'اضافة فاتورة مبيعات', '149196', '20215', '2024-12-12 18:16:22', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1300, 2135, 2135
                    , 2249, 2135, 2249, 2105
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1300, sellCostBuyPrice =sellCostBuyPrice+2135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2135, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2105
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 1300, 2135, 2135
                    , 2249, 2135, 2249, 2105
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1300, sellCostBuyPrice =sellCostBuyPrice+2135
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2135, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2249
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2135, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2249
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2105
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1300, 2135, 2135
                    , 2249, 2135, 2249, 2105, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1300, netSellCostBuyPrice = netSellCostBuyPrice+2135
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2135
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2249
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2135
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2249
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2105
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b0a1311df1 and sellbillId = 149196 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:46:23";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:16:23", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:16: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-12 14:46:27";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:16:27", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:16:27', '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-12 14:46:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:16:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:16: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 0675b0c5b97aa7
-- ----------------------------------------------------------------------------------------------------

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-12 18:16:27', '0675b0c5b97aa7', '1', '0.00', '0', '0', '1', '440', '440', '-440', '0', '1', '2024-12-12 18:16:46', '', '104', '0', 'نقدي','1', '0', '5', '26', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-440','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','اضافة فاتورة مردوات مبيعات','16743', '0', '2024-12-12 18:16:46', '104', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '440', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 18:16: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 ('360.00', 'H1455', '16743', '14', '15838', '1', '440', '440', '0', '', '1', '0', '15838', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','440','440','0','','0');
UPDATE returnsellbilldetail 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 returnsellbilldetailid = 21903;
 INSERT INTO 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 360, 360, 359
                    , 360, 359, 356.92, 0, 1, 0, 0, 360, 359)
                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+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+359, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+359
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+356.92
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+360
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+359
                        , 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 360, 360, 359
                    , 360, 359, 356.92, 0, 0, 360, 359)
                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+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+359, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+359
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+356.92
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+360
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+359;
UPDATE storedetail SET  productquantity = '15', userid = '104', storedetaildate = '2024-12-12 18:16:46' WHERE storedetailid = '15837';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15838', '1', '1', '0', '16743', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '14', '15', '104', '2024-12-12 18:16:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '19775',  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 ('20215','-440', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16743', '19775', '2024-12-12 18:16:46', '104',  'returnsellbillController.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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 360, 360, 359
                    , 360, 359, 356.92 ,0, 0, 360, 359)
                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+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+359, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+359
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+356.92
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+360
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+359;
 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 360, 360, 359
                    , 360, 359, 356.92 ,0, 0, 360, 359)
                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+360, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+360
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+359, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+360
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+359
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+356.92
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+360
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+359;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -440, -360, -360
                    , -359, -360, -359, -356.92, -360, -359)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-440, netSellCostBuyPrice = netSellCostBuyPrice+-360
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-360
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-359
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-360
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-359
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-356.92
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-360
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-359;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b0c5b97aa7 and sellbillId = 16743 and returnsellbillId = 16743
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:46:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:16:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:16:46', '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-12 14:46:49";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:16:49", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:16:49', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:47:16";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:17:16", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:17: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-12 14:47:38";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:17:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:17:38', '2', 'editsellBill', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=149153');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:48:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:18:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18: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 0675b0c8c45303
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8318,@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-12 18:17:16', '0675b0c8c45303', '8318', '21.00', '390', '0', '1', '369.00', '369', '0', '369', '1', '2024-12-12 18:18:32', '', '104', '0', 'مي عادل I1105', '1', '1', '3', '95', 'مي عادل I1105', '2' ,'0','','','','','-1','0','0','0','0','0','369','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '390', userid = '104' WHERE clientid = '8318';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8318','21.00','369','0','اضافة فاتورة مبيعات','149197', '390', '2024-12-12 18:18:32', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '369', '0', null, '0', null, null,'', '0','1','1','369','1','2024-12-12 18:17:16','0','0');
UPDATE client SET  inUse = 0 where clientid = 8318;
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', '149197', '1', '16322', '1', '365', '365', '0', '', '1', '2024-12-12 18:18:32', '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 = 545193;
 INSERT INTO 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-12', 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-12', 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 = '9', userid = '104', storedetaildate = '2024-12-12 18:18:32' WHERE storedetailid = '16321';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16322', '1', '1', '1', '149197', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '104', '2024-12-12 18:18: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', '149197', '17', '10291', '1', '4', '4', '0', '', '1', '2024-12-12 18:18:32', '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 = 95 where clientid = 8318;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 369, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+369, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8318, '2024-12-12', 369, 295, 295
                    , 295, 295, 295, 295
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,295, 295, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+369, sellCostBuyPrice =sellCostBuyPrice+295
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+295, sellCostMeanBuyPrice = sellCostMeanBuyPrice+295
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+295, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+295
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+295
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+295
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+295
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 369, 295, 295
                    , 295, 295, 295, 295, 295, 295)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+369, netSellCostBuyPrice = netSellCostBuyPrice+295
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+295
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+295
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+295
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+295
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+295
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+295
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+295;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b0c8c45303 and sellbillId = 149197 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:48:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:18:32", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:18: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-12 14:49:07";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:19:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:19:07', '2', 'update', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

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


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

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 149153;
UPDATE sellbill SET  sellbillsysdate = '2024-12-12 18:19:07', userid = '75',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '149153';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-2 where id = 36027;
UPDATE sellbilldetail SET  lastbuyprice = 435.00 , meanbuyprice = 414.00, lastbuyprice_withDiscount = 435.00, meanbuyprice_withDiscount = 414.00
        , lastbuyprice_withTax = 435, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 435
                where sellbilldetailid = 545010;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16255, '2024-12-12', 1200, 870, 870
                    , 828, 870, 828, 880
                    , 0, 0, 0, 0
                    , 0, 0, 0,2,0, 870, 960, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1200, sellCostBuyPrice =sellCostBuyPrice-870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-870, sellCostMeanBuyPrice = sellCostMeanBuyPrice-828
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-828
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-880
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-960
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-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-12', 1200, 870, 870
                    , 828, 870, 828, 880
                    , 0, 0, 0, 0
                    , 0, 0, 0, 870, 960, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1200, sellCostBuyPrice =sellCostBuyPrice-870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-870, sellCostMeanBuyPrice = sellCostMeanBuyPrice-828
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-828
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-880
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-960
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
UPDATE storedetail SET  productquantity = '22', userid = '2', storedetaildate = '2024-12-12 18:19:07' WHERE storedetailid = '16254';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16255', '1', '2', '0', '149153', 'تعديل فاتورة مبيعات', 'sellbillController.php', '20', '22', '2', '2024-12-12 15:38:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35845;
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 304.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 304.00
        , lastbuyprice_withTax = 300, meanbuyprice_withTax = 302, lastbuyprice_withDiscountAndTax = 300
                where sellbilldetailid = 545011;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16253, '2024-12-12', 410, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-410, sellCostBuyPrice =sellCostBuyPrice-300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-300, sellCostMeanBuyPrice = sellCostMeanBuyPrice-304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-302
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 410, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-410, sellCostBuyPrice =sellCostBuyPrice-300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-300, sellCostMeanBuyPrice = sellCostMeanBuyPrice-304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-302
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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 = '2', storedetaildate = '2024-12-12 18:19:07' WHERE storedetailid = '16252';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16253', '1', '1', '0', '149153', 'تعديل فاتورة مبيعات', 'sellbillController.php', '39', '40', '2', '2024-12-12 15:38:17','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:49:07";
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 34784;
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
        , lastbuyprice_withTax = 180, meanbuyprice_withTax = 108, lastbuyprice_withDiscountAndTax = 180
                where sellbilldetailid = 545012;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15434, '2024-12-12', 240, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 180, 108, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-240, sellCostBuyPrice =sellCostBuyPrice-180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-180, sellCostMeanBuyPrice = sellCostMeanBuyPrice-180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-108
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 240, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 108, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-240, sellCostBuyPrice =sellCostBuyPrice-180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-180, sellCostMeanBuyPrice = sellCostMeanBuyPrice-180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-108
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-12 18:19:07' WHERE storedetailid = '15433';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15434', '1', '1', '0', '149153', 'تعديل فاتورة مبيعات', 'sellbillController.php', '10', '11', '2', '2024-12-12 15:38:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35863;
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:19:07", deviceType = "DESKTOP" WHERE userid = 104;
UPDATE sellbilldetail SET  lastbuyprice = 255.00 , meanbuyprice = 255.00, lastbuyprice_withDiscount = 255.00, meanbuyprice_withDiscount = 255.00
        , lastbuyprice_withTax = 255, meanbuyprice_withTax = 255, lastbuyprice_withDiscountAndTax = 255
                where sellbilldetailid = 545013;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16269, '2024-12-12', 480, 255, 255
                    , 255, 255, 255, 255
                    , 0, 0, 0, 0
                    , 0, 0, 0,1,0, 255, 255, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-480, sellCostBuyPrice =sellCostBuyPrice-255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-255, sellCostMeanBuyPrice = sellCostMeanBuyPrice-255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-255
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-255
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-255
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0
                        , netQuantity = netQuantity-1
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 480, 255, 255
                    , 255, 255, 255, 255
                    , 0, 0, 0, 0
                    , 0, 0, 0, 255, 255, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-480, sellCostBuyPrice =sellCostBuyPrice-255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-255, sellCostMeanBuyPrice = sellCostMeanBuyPrice-255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-255
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-255
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-255
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = 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-12 18:19:07' WHERE storedetailid = '16268';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16269', '1', '1', '0', '149153', 'تعديل فاتورة مبيعات', 'sellbillController.php', '8', '9', '2', '2024-12-12 15:38:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 16056;
UPDATE sellbilldetail SET  lastbuyprice = 180.00 , meanbuyprice = 180.00, lastbuyprice_withDiscount = 180.00, meanbuyprice_withDiscount = 180.00
        
                where sellbilldetailid = 545014;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7705, '2024-12-12', 130, 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-130, 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-12', 130, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-130, 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 = '2', storedetaildate = '2024-12-12 18:19:07' WHERE storedetailid = '7704';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('7705', '1', '1', '0', '149153', 'تعديل فاتورة مبيعات', 'sellbillController.php', '2', '3', '2', '2024-12-12 15:38:17','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35878;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:19:07', '104', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');
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 = 545015;
 INSERT INTO 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-12', 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-12', 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 = '69', userid = '2', storedetaildate = '2024-12-12 18:19:07' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '0', '149153', 'تعديل فاتورة مبيعات', 'sellbillController.php', '68', '69', '2', '2024-12-12 15:38:17','0','0');
CALL clientInUse(1312,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-2197', userid = '2' WHERE clientid = '1312';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1312','1126.00','3323.00','1','تعديل فاتورة مبيعات','149153', '-2197', '2024-12-12 15:38:17', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '3323', '0', null, '0', null, null,'', '0','1','1','3323','1','2024-12-12 15:38:17','0','0');
UPDATE client SET  inUse = 0 where clientid = 1312;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 3323, 2515, 2515
                    , 2477, 2515, 2477, 2526.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2335, 2355, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-3323, sellCostBuyPrice =sellCostBuyPrice-2515
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-2515, sellCostMeanBuyPrice = sellCostMeanBuyPrice-2477
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-2515, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-2477
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-2526.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-2335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-2355
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1312, '2024-12-12', 3323, 2515, 2515
                    , 2477, 2515, 2477, 2526.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2335, 2355, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-3323, sellCostBuyPrice =sellCostBuyPrice-2515
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-2515, sellCostMeanBuyPrice = sellCostMeanBuyPrice-2477
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-2515, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-2477
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-2526.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-2335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-2355
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3323, 2515, 2515
                    , 2477, 2515, 2477, 2526.5, 2335, 2355)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-3323, netSellCostBuyPrice = netSellCostBuyPrice-2515
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-2515
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-2477
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-2515
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-2477
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-2526.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-2335
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-2355;

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


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

COMMIT;
BEGIN;
CALL clientInUse(1312,@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-12 15:38:17', '0675ae749cd2e2', '1312', '-2197.00', '1046', '0', '1', '3243', '3243', '0', '3243', '1', '2024-12-12 15:38:17', '', '2', '0', 'محمود السعيد s109', '2', '1', '3', '91', 'محمود السعيد s109', '9', '149153', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1046', userid = '2' WHERE clientid = '1312';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1312','-2197.00','3243','0','اضافة فاتورة مبيعات (معدله)','149198', '1046', '2024-12-12 18:19:07', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '3243', '0', null, '0', null, null,'', '0','1','1','3323','1','2024-12-12 15:38:17','0','0');
UPDATE client SET  inUse = 0 where clientid = 1312;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36027;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('435','H1621', '149198', '14', '16255', '2', '600', '1200', '0', '', '1', '2024-12-12 18:19:07', '16255', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36027-2,','1','1','0','0','600','1200','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 435.00 , meanbuyprice = 414.00, lastbuyprice_withDiscount = 435.00, meanbuyprice_withDiscount = 414.00
        , lastbuyprice_withTax = 435, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 435
                where sellbilldetailid = 545195;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16255, '2024-12-12', 1200, 870, 870
                    , 828, 870, 828, 880
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0, 870, 960, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+870, sellCostMeanBuyPrice = sellCostMeanBuyPrice+828
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+828
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+880
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+960
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+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-12', 1200, 870, 870
                    , 828, 870, 828, 880
                    , 0, 0, 0, 0
                    , 0, 0, 0, 870, 960, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+870
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+870, sellCostMeanBuyPrice = sellCostMeanBuyPrice+828
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+870, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+828
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+880
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+870
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+960
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '20', userid = '2', storedetaildate = '2024-12-12 18:19:07' WHERE storedetailid = '16254';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16255', '1', '2', '1', '149198', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '22', '20', '2', '2024-12-12 18:19:07','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35845;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1617', '149198', '14', '16253', '1', '410', '410', '0', '', '1', '2024-12-12 18:19:07', '16253', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35845-1,','1','1','0','0','410','410','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 304.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 304.00
        , lastbuyprice_withTax = 300, meanbuyprice_withTax = 302, lastbuyprice_withDiscountAndTax = 300
                where sellbilldetailid = 545196;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16253, '2024-12-12', 410, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+302
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 410, 300, 300
                    , 304, 300, 304, 301.5
                    , 0, 0, 0, 0
                    , 0, 0, 0, 300, 302, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+304
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+304
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+301.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+300
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+302
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '2', storedetaildate = '2024-12-12 18:19:07' WHERE storedetailid = '16252';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16253', '1', '1', '1', '149198', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '40', '39', '2', '2024-12-12 18:19:07','0','0');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b0cd909e07
-- ----------------------------------------------------------------------------------------------------

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-12 18:18:33', '0675b0cd909e07', '1', '0.00', '0', '0', '1', '255.00', '255', '255', '0', '1', '2024-12-12 18:19:07', '', '104', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','255','0','','0','0','255','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149199', '0', '2024-12-12 18:19:07', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '255', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 18:18:33','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32019;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34784;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06795', '149198', '5', '15434', '1', '165', '165', '0', '', '1', '2024-12-12 18:19:07', '15434', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34784-1,','1','1','0','0','165','165','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 ('270','R2922', '149199', '1', '14396', '1', '255', '255', '0', '', '1', '2024-12-12 18:19:07', '14396', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32019-1,','1','1','0','0','255','255','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 = 108, lastbuyprice_withDiscountAndTax = 180
                where sellbilldetailid = 545197;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15434, '2024-12-12', 165, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 180, 108, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+108
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 165, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 180, 108, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, sellCostBuyPrice =sellCostBuyPrice+180
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+180, sellCostMeanBuyPrice = sellCostMeanBuyPrice+180
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+180, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+180
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+180
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+180
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+108
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE sellbilldetail SET  lastbuyprice = 270.00 , meanbuyprice = 270.00, lastbuyprice_withDiscount = 270.00, meanbuyprice_withDiscount = 270.00
        
                where sellbilldetailid = 545198;
UPDATE storedetail SET  productquantity = '10', userid = '2', storedetaildate = '2024-12-12 18:19:07' WHERE storedetailid = '15433';
 INSERT INTO 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-12', 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 storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15434', '1', '1', '1', '149198', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '11', '10', '2', '2024-12-12 18:19:07','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35863;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('255','07186', '149198', '5', '16269', '1', '480', '480', '0', '', '1', '2024-12-12 18:19:07', '16269', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35863-1,','1','1','0','0','480','480','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 255.00 , meanbuyprice = 255.00, lastbuyprice_withDiscount = 255.00, meanbuyprice_withDiscount = 255.00
        , lastbuyprice_withTax = 255, meanbuyprice_withTax = 255, lastbuyprice_withDiscountAndTax = 255
                where sellbilldetailid = 545199;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16269, '2024-12-12', 480, 255, 255
                    , 255, 255, 255, 255
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 255, 255, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+255, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+255
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+255
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+255
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 480, 255, 255
                    , 255, 255, 255, 255
                    , 0, 0, 0, 0
                    , 0, 0, 0, 255, 255, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+255
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+255, sellCostMeanBuyPrice = sellCostMeanBuyPrice+255
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+255, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+255
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+255
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+255
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+255
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 18:19:07' WHERE storedetailid = '16268';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16269', '1', '1', '1', '149198', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '9', '8', '2', '2024-12-12 18:19:07','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 16056;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R1688', '149198', '1', '7705', '1', '125', '125', '0', '', '1', '2024-12-12 18:19:07', '7705', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','16056-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 = 545200;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7705, '2024-12-12', 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-12', 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 = '2', userid = '2', storedetaildate = '2024-12-12 18:19:07' WHERE storedetailid = '7704';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('7705', '1', '1', '1', '149198', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '3', '2', '2', '2024-12-12 18:19:07','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35878;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149198', '5', '16205', '1', '810', '810', '0', '', '1', '2024-12-12 18:19:07', '16205', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35878-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 = 545201;
 INSERT INTO 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-12', 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-12', 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 = '68', userid = '2', storedetaildate = '2024-12-12 18:19:07' WHERE storedetailid = '16204';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16205', '1', '1', '1', '149198', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '69', '68', '2', '2024-12-12 18: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 ('20','50235', '149198', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 18:19: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', '149198', '17', '10291', '1', '33', '33', '0', '', '1', '2024-12-12 18:19:08', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','33','33','0','','0','0.00','0','0','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 3243, 2515, 2515
                    , 2477, 2515, 2477, 2526.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2335, 2355, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3243, sellCostBuyPrice =sellCostBuyPrice+2515
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2515, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2477
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2515, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2477
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2526.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2355
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1312, '2024-12-12', 3243, 2515, 2515
                    , 2477, 2515, 2477, 2526.5
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,2335, 2355, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3243, sellCostBuyPrice =sellCostBuyPrice+2515
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2515, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2477
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2515, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2477
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2526.5
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2335
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2355
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 3243, 2515, 2515
                    , 2477, 2515, 2477, 2526.5, 2335, 2355)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3243, netSellCostBuyPrice = netSellCostBuyPrice+2515
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2515
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2477
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2515
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2477
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+2526.5
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+2335
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2355;
COMMIT;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 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;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 149153 and newid=149198 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE storedetail SET  productquantity = '3', userid = '104', storedetaildate = '2024-12-12 18:19:08' WHERE storedetailid = '14395';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14396', '1', '1', '1', '149199', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '104', '2024-12-12 18:19:08','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20030',  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 ('19775','255', '0', '1', 'اضافة فاتورة مبيعات', '149199', '20030', '2024-12-12 18:19:08', '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-12', 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;
 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-12', 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;
 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 0675b0cd909e07 and sellbillId = 149199 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:49:08";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:19:08", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:19: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-12 14:49:08";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:19:08", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:19:08', '2', 'editprint', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=149198');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:49:26";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:19:26", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 18:19:26', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:50:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:20:19", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:20: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-12 14:51:00";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:21:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 18:21:00', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245913
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245913 -clientdebtchangeId = 245919
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245920
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:52:25";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:22:25", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 18:22:25', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:53:32";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:23:32", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 18:23:32', '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-12 14:53:32";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:55:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:25:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:25:09', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:55:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:25:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:25:36', '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', 'فرق فاتورة سيل', '', '70', '2024-12-12', '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 = '19960',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('20030.00','70', '1', '1', 'إضافة مصروف', '25623', '19960', '2024-12-12 18:25:36', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'فرق فاتورة سيل', expensesdetails = '', expensesValue = '70.00', expensesdate = '2024-12-12', 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 = '25623';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:55:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:25:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:25: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-12 14:55:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:25:38", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:25:38', '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-12 14:55:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:25:54", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:25:54', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:56:01";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 18:26:02", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:26:02', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b02d430bb8
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(4292,@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-12 17:35:48', '0675b02d430bb8', '4292', '1.00', '1688', '0', '1', '1687.00', '1687', '0', '1687', '1', '2024-12-12 18:26:02', '', '75', '0', 'مني وهبة t66', '2', '1', '3', '89', 'مني وهبة t66', '8' ,'0','','','','','-1','0','0','0','0','0','1687','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1688', userid = '75' WHERE clientid = '4292';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('4292','1.00','1687','0','اضافة فاتورة مبيعات','149200', '1688', '2024-12-12 18:26:02', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1687', '0', null, '0', null, null,'', '0','1','1','1687','1','2024-12-12 17:35:48','0','0');
UPDATE client SET  inUse = 0 where clientid = 4292;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34490;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1304', '149200', '14', '15395', '1', '320', '320', '0', '', '1', '2024-12-12 18:26:02', '15395', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34490-1,','1','1','0','0','320','320','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        , lastbuyprice_withTax = 250, meanbuyprice_withTax = 76, lastbuyprice_withDiscountAndTax = 250
                where sellbilldetailid = 545204;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15395, '2024-12-12', 320, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 250, 76, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+76
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 320, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 250, 76, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+250
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+76
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 18:26:02' WHERE storedetailid = '15394';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15395', '1', '1', '1', '149200', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-12 18:26:02','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', '149200', '14', '16259', '1', '360', '360', '0', '', '1', '2024-12-12 18:26:02', '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 = 545205;
 INSERT INTO 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-12', 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-12', 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 = '13', userid = '75', storedetaildate = '2024-12-12 18:26:02' WHERE storedetailid = '16258';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16259', '1', '1', '1', '149200', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-12 18:26:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35801;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149200', '5', '16224', '1', '300', '300', '0', '', '1', '2024-12-12 18:26:02', '16224', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35801-1,','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 = 545206;
 INSERT INTO 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-12', 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-12', 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 = '3', userid = '75', storedetaildate = '2024-12-12 18:26:02' WHERE storedetailid = '16223';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16224', '1', '1', '1', '149200', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-12 18:26:02','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('175','R3220', '149200', '1', '15494', '1', '165', '165', '0', '', '1', '2024-12-12 18:26:02', '15494', '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 = 175.00 , meanbuyprice = 175.00, lastbuyprice_withDiscount = 175.00, meanbuyprice_withDiscount = 175.00
        
                where sellbilldetailid = 545207;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15494, '2024-12-12', 165, 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+165, 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-12', 165, 175, 175
                    , 175, 175, 175, 175
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, 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 = '0', userid = '75', storedetaildate = '2024-12-12 18:26:02' WHERE storedetailid = '15493';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15494', '1', '1', '1', '149200', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-12 18:26:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34547;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06843', '149200', '5', '15568', '1', '120', '120', '0', '', '1', '2024-12-12 18:26:02', '15568', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34547-1,','1','1','0','0','120','120','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 160.00 , meanbuyprice = 159.00, lastbuyprice_withDiscount = 160.00, meanbuyprice_withDiscount = 159.00
        , lastbuyprice_withTax = 160, meanbuyprice_withTax = 120, lastbuyprice_withDiscountAndTax = 160
                where sellbilldetailid = 545208;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15568, '2024-12-12', 120, 160, 160
                    , 159, 160, 159, 158.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 160, 120, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+159
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+159
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+158.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+120
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 120, 160, 160
                    , 159, 160, 159, 158.33
                    , 0, 0, 0, 0
                    , 0, 0, 0, 160, 120, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+159
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+159
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+158.33
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+160
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+120
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '75', storedetaildate = '2024-12-12 18:26:02' WHERE storedetailid = '15567';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15568', '1', '1', '1', '149200', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '75', '2024-12-12 18:26:02','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 24609;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','05181', '149200', '5', '11219', '1', '385', '385', '0', '', '1', '2024-12-12 18:26:02', '11219', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','24609-1,','1','1','0','0','385','385','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 = 545209;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11219, '2024-12-12', 385, 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+385, 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-12', 385, 350, 350
                    , 350, 350, 350, 350
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+385, 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 = '2', userid = '75', storedetaildate = '2024-12-12 18:26:02' WHERE storedetailid = '11218';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11219', '1', '1', '1', '149200', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '75', '2024-12-12 18:26:02','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149200', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 18:26:02', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149200', '17', '10291', '1', '17', '17', '0', '', '1', '2024-12-12 18:26:02', '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 = 89 where clientid = 4292;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1687, 1475, 1475
                    , 1477, 1475, 1477, 1480
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,950, 742, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1687, sellCostBuyPrice =sellCostBuyPrice+1475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1477
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1477
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+950
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+742
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (4292, '2024-12-12', 1687, 1475, 1475
                    , 1477, 1475, 1477, 1480
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,950, 742, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1687, sellCostBuyPrice =sellCostBuyPrice+1475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1477
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1477
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1480
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+950
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+742
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1687, 1475, 1475
                    , 1477, 1475, 1477, 1480, 950, 742)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1687, netSellCostBuyPrice = netSellCostBuyPrice+1475
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1475
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1477
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1475
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1477
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1480
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+950
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+742;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b02d430bb8 and sellbillId = 149200 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:56:03";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 18:26:03", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:26: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-12 14:56:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:26:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:26:07', '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-12', '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 = '19950',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('19960.00','10', '1', '1', 'إضافة مصروف', '25624', '19950', '2024-12-12 18:26:07', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'فرق فاتورة', expensesdetails = '', expensesValue = '10.00', expensesdate = '2024-12-12', 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 = '25624';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:56:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:26:07", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:26:07', '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-12 14:56:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:26:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:26:09', '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-12 14:56:35";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:26:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:26:35', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:56:35";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:26:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:26: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-12 14:56:36";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:26:36", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:26:36', '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-12 14:57:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:27:33", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:27: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 0675b0ebca079b
-- ----------------------------------------------------------------------------------------------------

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-12 18:26:36', '0675b0ebca079b', '1', '0.00', '0', '0', '1', '155.00', '155', '155', '0', '1', '2024-12-12 18:27:33', '', '104', '0', 'نقدي', '1', '0', '3', '92', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','155','0','','0','0','155','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149201', '0', '2024-12-12 18:27:33', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '155', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 18:26: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 ('165','06739', '149201', '5', '15294', '1', '155', '155', '0', '', '1', '2024-12-12 18:27:33', '15294', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','155','155','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 165.00 , meanbuyprice = 165.00, lastbuyprice_withDiscount = 165.00, meanbuyprice_withDiscount = 165.00
        
                where sellbilldetailid = 545212;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15294, '2024-12-12', 155, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , 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-12', 155, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '-3', userid = '104', storedetaildate = '2024-12-12 18:27:33' WHERE storedetailid = '15293';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15294', '1', '1', '1', '149201', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-2', '-3', '104', '2024-12-12 18:27:33','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20105',  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 ('19950','155', '0', '1', 'اضافة فاتورة مبيعات', '149201', '20105', '2024-12-12 18:27:33', '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-12', 155, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 155, 165, 165
                    , 165, 165, 165, 165
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+155, sellCostBuyPrice =sellCostBuyPrice+165
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+165, sellCostMeanBuyPrice = sellCostMeanBuyPrice+165
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+165, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+165
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+165
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 155, 165, 165
                    , 165, 165, 165, 165, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+155, netSellCostBuyPrice = netSellCostBuyPrice+165
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+165
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+165
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+165
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+165
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+165
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b0ebca079b and sellbillId = 149201 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b0e9b7b3ea
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(7037,@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-12 18:26:03', '0675b0e9b7b3ea', '7037', '0.00', '1606', '0', '1', '1606.00', '1606', '0', '1606', '1', '2024-12-12 18:29:25', '', '75', '0', 'مي اسامة D27', '2', '1', '3', '81', 'مي اسامة D27', '9' ,'0','','','','','-1','0','0','0','0','0','1606','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1606', userid = '75' WHERE clientid = '7037';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('7037','0.00','1606','0','اضافة فاتورة مبيعات','149202', '1606', '2024-12-12 18:29:25', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1606', '0', null, '0', null, null,'', '0','1','1','1606','1','2024-12-12 18:26:03','0','0');
UPDATE client SET  inUse = 0 where clientid = 7037;
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', '149202', '5', '16061', '1', '285', '285', '0', '', '1', '2024-12-12 18:29:25', '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 = 545213;
 INSERT INTO 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-12', 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-12', 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 = '7', userid = '75', storedetaildate = '2024-12-12 18:29:25' WHERE storedetailid = '16060';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16061', '1', '1', '1', '149202', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '75', '2024-12-12 18:29:25','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35469;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07075', '149202', '5', '16070', '1', '230', '230', '0', '', '1', '2024-12-12 18:29:25', '16070', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35469-1,','1','1','0','0','230','230','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 = 545214;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16070, '2024-12-12', 230, 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+230, 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-12', 230, 160, 160
                    , 160, 160, 160, 160
                    , 0, 0, 0, 0
                    , 0, 0, 0, 160, 160, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+230, 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 = '5', userid = '75', storedetaildate = '2024-12-12 18:29:25' WHERE storedetailid = '16069';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16070', '1', '1', '1', '149202', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '75', '2024-12-12 18:29:25','0','0');
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', '149202', '5', '16125', '1', '200', '200', '0', '', '1', '2024-12-12 18:29:25', '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 = 545215;
 INSERT INTO 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-12', 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-12', 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 = '13', userid = '75', storedetaildate = '2024-12-12 18:29:25' WHERE storedetailid = '16124';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16125', '1', '1', '1', '149202', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '75', '2024-12-12 18:29: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 ('220','05409', '149202', '5', '11789', '1', '120', '120', '0', '', '1', '2024-12-12 18:29:25', '11789', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','120','120','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 230.00 , meanbuyprice = 235.00, lastbuyprice_withDiscount = 230.00, meanbuyprice_withDiscount = 235.00
        
                where sellbilldetailid = 545216;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (11789, '2024-12-12', 120, 220, 230
                    , 235, 230, 235, 216.82
                    , 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+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+216.82
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 120, 220, 230
                    , 235, 230, 235, 216.82
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+120, sellCostBuyPrice =sellCostBuyPrice+220
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+216.82
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 18:29:25' WHERE storedetailid = '11788';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('11789', '1', '1', '1', '149202', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '75', '2024-12-12 18:29:25','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35728;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('190','07067', '149202', '5', '16076', '1', '250', '250', '0', '', '1', '2024-12-12 18:29:25', '16076', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35728-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 190.00 , meanbuyprice = 190.00, lastbuyprice_withDiscount = 190.00, meanbuyprice_withDiscount = 190.00
        , lastbuyprice_withTax = 190, meanbuyprice_withTax = 190, lastbuyprice_withDiscountAndTax = 190
                where sellbilldetailid = 545217;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16076, '2024-12-12', 250, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+190
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 250, 190, 190
                    , 190, 190, 190, 190
                    , 0, 0, 0, 0
                    , 0, 0, 0, 190, 190, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+190, sellCostMeanBuyPrice = sellCostMeanBuyPrice+190
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+190, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+190
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+190
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+190
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+190
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '8', userid = '75', storedetaildate = '2024-12-12 18:29:25' WHERE storedetailid = '16075';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16076', '1', '1', '1', '149202', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '75', '2024-12-12 18:29:25','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 34316;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06816', '149202', '5', '15516', '1', '165', '165', '0', '', '1', '2024-12-12 18:29:25', '15516', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34316-1,','1','1','0','0','165','165','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 = 545218;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15516, '2024-12-12', 165, 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+165, 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-12', 165, 180, 180
                    , 180, 180, 180, 180
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+165, 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 = '75', storedetaildate = '2024-12-12 18:29:25' WHERE storedetailid = '15515';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15516', '1', '1', '1', '149202', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4', '3', '75', '2024-12-12 18:29: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 ('260','H1451', '149202', '14', '15832', '1', '320', '320', '0', '', '1', '2024-12-12 18:29:25', '15832', '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 = 260.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 260.00
        , lastbuyprice_withTax = 260, meanbuyprice_withTax = 260, lastbuyprice_withDiscountAndTax = 260
                where sellbilldetailid = 545219;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15832, '2024-12-12', 320, 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+320, 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-12', 320, 260, 260
                    , 260, 260, 260, 260
                    , 0, 0, 0, 0
                    , 0, 0, 0, 260, 260, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, sellCostBuyPrice =sellCostBuyPrice+260
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+260, sellCostMeanBuyPrice = sellCostMeanBuyPrice+260
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+260, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+260
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+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 = '-2', userid = '75', storedetaildate = '2024-12-12 18:29:25' WHERE storedetailid = '15831';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15832', '1', '1', '1', '149202', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-1', '-2', '75', '2024-12-12 18:29:25','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149202', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 18:29:25', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149202', '17', '10291', '1', '16', '16', '0', '', '1', '2024-12-12 18:29:25', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','16','16','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 81 where clientid = 7037;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1606, 1415, 1425
                    , 1430, 1425, 1430, 1411.82
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1015, 1015, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1606, sellCostBuyPrice =sellCostBuyPrice+1415
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1411.82
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1015
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1015
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (7037, '2024-12-12', 1606, 1415, 1425
                    , 1430, 1425, 1430, 1411.82
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1015, 1015, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1606, sellCostBuyPrice =sellCostBuyPrice+1415
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1425, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1425, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1411.82
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1015
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1015
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1606, 1415, 1425
                    , 1430, 1425, 1430, 1411.82, 1015, 1015)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1606, netSellCostBuyPrice = netSellCostBuyPrice+1415
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1425
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1430
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1425
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1430
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1411.82
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1015
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1015;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b0e9b7b3ea and sellbillId = 149202 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 14:59:26";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 18:29:26", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:29: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-12 14:59:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:29:48", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:29: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 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-12 14:59:48";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 18:29:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 18:29:49', '1', '', '192.168.1.73', '', '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-12 14:59:50";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:00:05";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 18:30:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storeController.php', '2024-12-12 18:30:05', '1', 'show', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storeController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:00:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:30:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:30: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 0675b0f7c61cd0
-- ----------------------------------------------------------------------------------------------------

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-12 18:29:48', '0675b0f7c61cd0', '1', '0.00', '0', '0', '1', '250.00', '250', '250', '0', '1', '2024-12-12 18:30:10', '', '104', '0', 'نقدي', '1', '0', '3', '73', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','250','0','','0','0','250','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149203', '0', '2024-12-12 18:30:10', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '250', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 18:29:48','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33652;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('535','06545', '149203', '5', '14961', '1', '250', '250', '0', '', '1', '2024-12-12 18:30:10', '14961', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33652-1,','1','1','0','0','250','250','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 535.00 , meanbuyprice = 525.00, lastbuyprice_withDiscount = 535.00, meanbuyprice_withDiscount = 525.00
        
                where sellbilldetailid = 545222;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14961, '2024-12-12', 250, 535, 535
                    , 525, 535, 525, 523.75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+535
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+535, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+523.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 250, 535, 535
                    , 525, 535, 525, 523.75
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+535
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+535, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+523.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 18:30:10' WHERE storedetailid = '14960';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14961', '1', '1', '1', '149203', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11', '10', '104', '2024-12-12 18:30:10','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20355',  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 ('20105','250', '0', '1', 'اضافة فاتورة مبيعات', '149203', '20355', '2024-12-12 18:30:10', '104',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 73 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 250, 535, 535
                    , 525, 535, 525, 523.75
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+535
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+535, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+523.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 250, 535, 535
                    , 525, 535, 525, 523.75
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+535
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+535, sellCostMeanBuyPrice = sellCostMeanBuyPrice+525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+523.75
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 250, 535, 535
                    , 525, 535, 525, 523.75, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+250, netSellCostBuyPrice = netSellCostBuyPrice+535
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+535
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+525
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+535
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+525
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+523.75
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b0f7c61cd0 and sellbillId = 149203 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:00:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:30:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:30: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-12 15:01:02";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 18:31:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('saveController.php', '2024-12-12 18:31:02', '1', 'show', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/saveController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:01:39";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 18:31:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 18:31:39', '1', 'show', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:01:40";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 18:31:40", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:31:40', '75', 'addAndRetuen', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b0f66841ee
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(8653,@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-12 18:29:26', '0675b0f66841ee', '8653', '15.00', '833', '0', '1', '818.00', '818', '0', '818', '1', '2024-12-12 18:31:40', '', '75', '0', 'ام ملك قليوب W890', '2', '1', '3', '83', 'ام ملك قليوب W890', '4' ,'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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '833', userid = '75' WHERE clientid = '8653';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('8653','15.00','818','0','اضافة فاتورة مبيعات','149204', '833', '2024-12-12 18:31:40', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '818', '0', null, '0', null, null,'', '0','1','1','818','1','2024-12-12 18:29:26','0','0');
UPDATE client SET  inUse = 0 where clientid = 8653;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35933;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('170','07203', '149204', '5', '16308', '1', '220', '220', '0', '', '1', '2024-12-12 18:31:41', '16308', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35933-1,','1','1','0','0','220','220','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 170.00 , meanbuyprice = 170.00, lastbuyprice_withDiscount = 170.00, meanbuyprice_withDiscount = 170.00
        , lastbuyprice_withTax = 170, meanbuyprice_withTax = 170, lastbuyprice_withDiscountAndTax = 170
                where sellbilldetailid = 545223;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16308, '2024-12-12', 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-12', 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 = '9', userid = '75', storedetaildate = '2024-12-12 18:31:41' WHERE storedetailid = '16307';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16308', '1', '1', '1', '149204', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-12 18:31:41','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', '149204', '14', '15689', '1', '570', '570', '0', '', '1', '2024-12-12 18:31:41', '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 = 545224;
 INSERT INTO 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-12', 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-12', 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 = '16', userid = '75', storedetaildate = '2024-12-12 18:31:41' WHERE storedetailid = '15688';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15689', '1', '1', '1', '149204', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17', '16', '75', '2024-12-12 18:31:41','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149204', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 18:31:41', '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', '149204', '17', '10291', '1', '8', '8', '0', '', '1', '2024-12-12 18:31:41', '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 = 83 where clientid = 8653;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 818, 660, 660
                    , 660, 660, 660, 660
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,660, 660, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+818, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+660
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+660
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+660
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (8653, '2024-12-12', 818, 660, 660
                    , 660, 660, 660, 660
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,660, 660, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+818, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+660
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+660
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+660
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 818, 660, 660
                    , 660, 660, 660, 660, 660, 660)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+818, netSellCostBuyPrice = netSellCostBuyPrice+660
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+660
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+660
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+660
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+660
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+660
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+660
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+660;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b0f66841ee and sellbillId = 149204 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:01:41";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 18:31:41", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:31:41', '75', 'addsellBill', '192.168.1.57', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=3');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:01:48";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 18:31:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('storeController.php', '2024-12-12 18:31:48', '1', 'show', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/storeController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:03:17";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:33:17", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:33:17', '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-12 15:03:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:33:34", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:33: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 0675b0f93b5683
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(5615,@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-12 18:30:11', '0675b0f93b5683', '5615', '2.00', '810', '0', '1', '808.00', '808', '0', '808', '1', '2024-12-12 18:33:35', '', '104', '0', 'داليا مصطفي f137', '1', '1', '3', '26', 'داليا مصطفي f137', '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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '810', userid = '104' WHERE clientid = '5615';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('5615','2.00','808','0','اضافة فاتورة مبيعات','149205', '810', '2024-12-12 18:33:35', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '808', '0', null, '0', null, null,'', '0','1','1','808','1','2024-12-12 18:30:11','0','0');
UPDATE client SET  inUse = 0 where clientid = 5615;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35711;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149205', '5', '16210', '1', '420', '420', '0', '', '1', '2024-12-12 18:33:35', '16210', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35711-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 = 545227;
 INSERT INTO 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-12', 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-12', 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 = '31', userid = '104', storedetaildate = '2024-12-12 18:33:35' WHERE storedetailid = '16209';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16210', '1', '1', '1', '149205', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32', '31', '104', '2024-12-12 18:33:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 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', '149205', '1', '16186', '1', '380', '380', '0', '', '1', '2024-12-12 18:33:35', '16186', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35938-1,','1','1','0','0','380','380','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 310.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 310.00
        , lastbuyprice_withTax = 310, meanbuyprice_withTax = 310, lastbuyprice_withDiscountAndTax = 310
                where sellbilldetailid = 545228;
 INSERT INTO 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-12', 380, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 380, 310, 310
                    , 310, 310, 310, 310
                    , 0, 0, 0, 0
                    , 0, 0, 0, 310, 310, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+310
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+310
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+310
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '26', userid = '104', storedetaildate = '2024-12-12 18:33:35' WHERE storedetailid = '16185';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16186', '1', '1', '1', '149205', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27', '26', '104', '2024-12-12 18:33: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 ('0','10291', '149205', '17', '10291', '1', '8', '8', '0', '', '1', '2024-12-12 18:33:35', '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 = 26 where clientid = 5615;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 808, 685, 685
                    , 685, 685, 685, 685
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,685, 685, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+808, sellCostBuyPrice =sellCostBuyPrice+685
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+685, sellCostMeanBuyPrice = sellCostMeanBuyPrice+685
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+685, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+685
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+685
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+685
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+685
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (5615, '2024-12-12', 808, 685, 685
                    , 685, 685, 685, 685
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,685, 685, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+808, sellCostBuyPrice =sellCostBuyPrice+685
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+685, sellCostMeanBuyPrice = sellCostMeanBuyPrice+685
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+685, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+685
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+685
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+685
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+685
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 685, 685
                    , 685, 685, 685, 685, 685, 685)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+808, netSellCostBuyPrice = netSellCostBuyPrice+685
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+685
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+685
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+685
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+685
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+685
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+685
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+685;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b0f93b5683 and sellbillId = 149205 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:03:35";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:33:35", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:33:35', '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 ('محمد خليفة' , '', '01020670597', '', '0', '', '0', '2024-12-12 18:34:10', '101', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-12','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10685', '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 ('10685','0','0','0','إضافة عميل جديد','10685', '0', '2024-12-12 18:34:10', '101', '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', '', '101', '0', '2024-12-12 18:34:10');
UPDATE client SET clientname = 'محمد خليفة', clientaddress = '', clientphone = '01020670597', clientmobile = '', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-12', userid = '101'  , 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='12430',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10685';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:05:19";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:35:19", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:35:19', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b104d78cab
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10685,@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-12 18:33:17', '0675b104d78cab', '10685', '0.00', '838', '0', '1', '838.00', '838', '0', '838', '1', '2024-12-12 18:35:19', '', '101', '0', 'محمد خليفة', '2', '1', '3', '73', 'محمد خليفة', '3' ,'0','','','','','-1','0','0','0','0','0','838','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '838', userid = '101' WHERE clientid = '10685';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10685','0.00','838','0','اضافة فاتورة مبيعات','149206', '838', '2024-12-12 18:35:19', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '838', '0', null, '0', null, null,'', '0','1','1','838','1','2024-12-12 18:33:17','0','0');
UPDATE client SET  inUse = 0 where clientid = 10685;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36051;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('735','07231', '149206', '5', '16342', '1', '810', '810', '0', '', '1', '2024-12-12 18:35:19', '16342', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36051-1,','1','1','0','0','810','810','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 735.00 , meanbuyprice = 732.00, lastbuyprice_withDiscount = 735.00, meanbuyprice_withDiscount = 732.00
        , lastbuyprice_withTax = 735, meanbuyprice_withTax = 728, lastbuyprice_withDiscountAndTax = 735
                where sellbilldetailid = 545230;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16342, '2024-12-12', 810, 735, 735
                    , 732, 735, 732, 735
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 735, 728, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+732
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+732
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+735
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+728
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 810, 735, 735
                    , 732, 735, 732, 735
                    , 0, 0, 0, 0
                    , 0, 0, 0, 735, 728, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+732
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+732
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+735
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+728
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '17', userid = '101', storedetaildate = '2024-12-12 18:35:19' WHERE storedetailid = '16341';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16342', '1', '1', '1', '149206', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18', '17', '101', '2024-12-12 18:35: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', '149206', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 18:35: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', '149206', '17', '10291', '1', '8', '8', '0', '', '1', '2024-12-12 18:35:19', '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 = 73 where clientid = 10685;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 838, 735, 735
                    , 732, 735, 732, 735
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,735, 728, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+838, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+732
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+732
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+735
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+728
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10685, '2024-12-12', 838, 735, 735
                    , 732, 735, 732, 735
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,735, 728, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+838, sellCostBuyPrice =sellCostBuyPrice+735
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+735, sellCostMeanBuyPrice = sellCostMeanBuyPrice+732
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+735, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+732
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+735
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+735
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+728
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 838, 735, 735
                    , 732, 735, 732, 735, 735, 728)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+838, netSellCostBuyPrice = netSellCostBuyPrice+735
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+735
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+732
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+735
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+732
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+735
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+735
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+728;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b104d78cab and sellbillId = 149206 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245921
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245921 -clientdebtchangeId = 245929
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:05:46";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:35:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 18:35:46', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:05:57";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 18:35:57", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:35: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-12 15:06:09";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 18:36:09", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:36:09', '101', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149206');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:06:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:36:46", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:36: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 0675b105fea864
-- ----------------------------------------------------------------------------------------------------

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-12 18:33:35', '0675b105fea864', '1', '0.00', '0', '0', '1', '400.00', '400', '400', '0', '1', '2024-12-12 18:36:46', '', '104', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','400','0','','0','0','400','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149207', '0', '2024-12-12 18:36:46', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '400', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 18:33:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35644;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149207', '5', '15328', '1', '400', '400', '0', '', '1', '2024-12-12 18:36:46', '15328', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35644-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 = 545233;
 INSERT INTO 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-12', 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-12', 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 = '4', userid = '104', storedetaildate = '2024-12-12 18:36:46' WHERE storedetailid = '15327';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15328', '1', '1', '1', '149207', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '104', '2024-12-12 18:36:46','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20755',  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 ('20355','400', '0', '1', 'اضافة فاتورة مبيعات', '149207', '20755', '2024-12-12 18:36: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-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 400, 350, 350
                    , 350, 350, 350, 350, 350, 350)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+400, 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 0675b105fea864 and sellbillId = 149207 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245930
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245930 -clientdebtchangeId = 245931
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:07:07";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:37:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 18:37:07', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:07:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:37:51", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:37: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-12 15:08:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:38:29", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:38: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-12 15:08:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:38:30", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:38:30', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:09:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:39:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:39:10', '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', 'كرت شحن', '', '40', '2024-12-12', '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 = '20715',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('20755.00','40', '1', '1', 'إضافة مصروف', '25625', '20715', '2024-12-12 18:39:10', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كرت شحن', expensesdetails = '', expensesValue = '40.00', expensesdate = '2024-12-12', 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 = '25625';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:09:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:39:10", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:39:10', '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-12 15:09:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:39:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:39: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-12 15:09:14";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 18:39:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 18:39:14', '1', 'show', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:09:31";
UPDATE user SET loginip = "192.168.1.73", lastactivetime = "2024-12-12 18:39:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('buyBillController.php', '2024-12-12 18:39:31', '1', 'show', '192.168.1.73', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/buyBillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:09:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:39:41", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:39: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 0675b11afef830
-- ----------------------------------------------------------------------------------------------------

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-12 18:39:11', '0675b11afef830', '1', '0.00', '0', '0', '1', '55.00', '55', '55', '0', '1', '2024-12-12 18:39:41', '', '104', '0', 'نقدي', '1', '0', '3', '94', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','55','0','','0','0','55','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','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','اضافة فاتورة مبيعات','149208', '0', '2024-12-12 18:39:41', '104', 'sellbillController.php', 'اضافة فاتورة مبيعات', '55', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 18:39:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32713;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('85','R2867', '149208', '1', '14243', '1', '55', '55', '0', '', '1', '2024-12-12 18:39:41', '14243', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32713-1,','1','1','0','0','55','55','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 85.00 , meanbuyprice = 85.00, lastbuyprice_withDiscount = 85.00, meanbuyprice_withDiscount = 85.00
        
                where sellbilldetailid = 545234;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14243, '2024-12-12', 55, 85, 85
                    , 85, 85, 85, 85
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+55, sellCostBuyPrice =sellCostBuyPrice+85
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+85, sellCostMeanBuyPrice = sellCostMeanBuyPrice+85
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+85, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+85
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+85
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 55, 85, 85
                    , 85, 85, 85, 85
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+55, sellCostBuyPrice =sellCostBuyPrice+85
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+85, sellCostMeanBuyPrice = sellCostMeanBuyPrice+85
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+85, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+85
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+85
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 18:39:41' WHERE storedetailid = '14242';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14243', '1', '1', '1', '149208', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1', '0', '104', '2024-12-12 18:39:41','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20770',  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 ('20715','55', '0', '1', 'اضافة فاتورة مبيعات', '149208', '20770', '2024-12-12 18:39:41', '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-12', 55, 85, 85
                    , 85, 85, 85, 85
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+55, sellCostBuyPrice =sellCostBuyPrice+85
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+85, sellCostMeanBuyPrice = sellCostMeanBuyPrice+85
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+85, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+85
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+85
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 55, 85, 85
                    , 85, 85, 85, 85
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+55, sellCostBuyPrice =sellCostBuyPrice+85
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+85, sellCostMeanBuyPrice = sellCostMeanBuyPrice+85
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+85, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+85
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+85
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 55, 85, 85
                    , 85, 85, 85, 85, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+55, netSellCostBuyPrice = netSellCostBuyPrice+85
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+85
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+85
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+85
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+85
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+85
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b11afef830 and sellbillId = 149208 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:09:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:39:42", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:39: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-12 15:09:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:39:56", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:39:56', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:10:08";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:40:08", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:40:08', '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-12', '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 = '20670',  userid = '104' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('20770.00','100', '1', '1', 'إضافة مصروف', '25626', '20670', '2024-12-12 18:40:08', '104',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'ايمان', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-12', 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 = '25626';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:10:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:40:09", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:40: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-12 15:10:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:40:11", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 18:40: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-12 15:10:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:40:12", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 18:40:12', '104', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:10:28";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:40:28", deviceType = "DESKTOP" WHERE userid = 104;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 18:40:28', '104', 'show', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.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-12 15:15:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:45:12", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 18:45: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-12 15:15:12";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:15:22";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:45:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 18:45:22', '2', 'add', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245932
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10685,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '-2' , clientdate = '2024-12-12 18:45:22', userid = '2' WHERE clientid = '10685';
UPDATE client SET  inUse = 0 where clientid = 10685;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10685','838.00','840','1','ايصال تحصيل (( قبض من عميل ))','245932', '-2', '2024-12-12 18:37:07', '2', 'clientPayedDeptController.php', '   ', '840', '0', null, '0', null, null,'', '-1','1','1','840','1','','3180','0');
UPDATE save SET  savecurrentvalue = '513543.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('512703.50','840', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245933', '513543.5', '2024-12-12 18:45:22', '2',  'clientPayedDeptController.php','0','','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid,isopeningentry,operationId,operationDetailLink) VALUES ( '840', '840', '2024-12-12', '2', '0', '0', '2024-12-12 18:45:22','اضافة ايصال سداد للعميل محمد خليفة','1','0','0','0','245933','clientPayedDeptController.php?do=show&id=245933');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121763', '-1', '840', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '840', 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 ('121763', '12430', '840', '','0');
UPDATE accountstree SET name = 'محمد خليفة', customName = 'محمد خليفة', customNameEn = 'محمد خليفة', nameEn = 'محمد خليفة', parent = '58', accountNature = '0', theValue = '-840', theOrder = '0', layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '101', del = '0', sysdate = '2024-12-12 18:34:10' WHERE id = '12430';
UPDATE clientdebtchange SET clientid = '10685', clientdebtchangebefore = '838.000', clientdebtchangeamount = '840.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245932', clientdebtchangeafter = '-2.000', clientdebtchangedate = '2024-12-12 18:37:07', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '840.00',discount='', reciptid='0', dailyentryid = '121763',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='840',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245933';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245932 -clientdebtchangeId = 245933
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b0feddf3c9
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2955,@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-12 18:31:41', '0675b0feddf3c9', '2955', '0.00', '606', '0', '1', '606.00', '606', '0', '606', '1', '2024-12-12 18:46:54', '', '75', '0', 'منة عمرو B650', '2', '1', '3', '78', 'منة عمرو B650', '4' ,'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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '606', userid = '75' WHERE clientid = '2955';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2955','0.00','606','0','اضافة فاتورة مبيعات','149209', '606', '2024-12-12 18:46:54', '75', 'sellbillController.php', 'اضافة فاتورة مبيعات', '606', '0', null, '0', null, null,'', '0','1','1','606','1','2024-12-12 18:31:41','0','0');
UPDATE client SET  inUse = 0 where clientid = 2955;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36143;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07103', '149209', '5', '16386', '1', '380', '380', '0', '', '1', '2024-12-12 18:46:54', '16386', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36143-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 = 545235;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16386, '2024-12-12', 380, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+330
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 380, 330, 330
                    , 330, 330, 330, 330
                    , 0, 0, 0, 0
                    , 0, 0, 0, 330, 330, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+330
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+330
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+330
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '12', userid = '75', storedetaildate = '2024-12-12 18:46:54' WHERE storedetailid = '16385';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16386', '1', '1', '1', '149209', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '12', '75', '2024-12-12 18:46:54','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', '149209', '1', '16188', '1', '200', '200', '0', '', '1', '2024-12-12 18:46:54', '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 = 545236;
 INSERT INTO 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-12', 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-12', 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 = '9', userid = '75', storedetaildate = '2024-12-12 18:46:54' WHERE storedetailid = '16187';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16188', '1', '1', '1', '149209', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10', '9', '75', '2024-12-12 18:46:54','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('20','50235', '149209', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 18:46:55', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149209', '17', '10291', '1', '6', '6', '0', '', '1', '2024-12-12 18:46:55', '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 = 78 where clientid = 2955;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 606, 475, 475
                    , 474, 475, 474, 477.46
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,475, 478, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+606, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+474
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+474
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+477.46
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+475
                            , 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2955, '2024-12-12', 606, 475, 475
                    , 474, 475, 474, 477.46
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,475, 478, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+606, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+474
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+474
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+477.46
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+475
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 606, 475, 475
                    , 474, 475, 474, 477.46, 475, 478)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+606, netSellCostBuyPrice = netSellCostBuyPrice+475
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+475
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+474
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+475
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+474
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+477.46
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+475
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+478;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b0feddf3c9 and sellbillId = 149209 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:16:55";
UPDATE user SET loginip = "192.168.1.57", lastactivetime = "2024-12-12 18:46:55", deviceType = "DESKTOP" WHERE userid = 75;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:46: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 userid = 75;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:20:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:50:42", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 18:50:42', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:26:33";
UPDATE user SET loginip = "192.168.1.27", lastactivetime = "2024-12-12 18:56:33", deviceType = "DESKTOP" WHERE userid = 101;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:56:33', '101', 'addAndRetuen', '192.168.1.27', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b10c82ec74
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1312,@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-12 18:35:20', '0675b10c82ec74', '1312', '1046.00', '1187', '0', '1', '141.00', '141', '0', '141', '1', '2024-12-12 18:56:33', '', '101', '0', 'محمود السعيد s109', '2', '1', '3', '91', 'محمود السعيد s109', '2' ,'0','','','','','-1','0','0','0','0','0','141','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1187', userid = '101' WHERE clientid = '1312';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1312','1046.00','141','0','اضافة فاتورة مبيعات','149210', '1187', '2024-12-12 18:56:33', '101', 'sellbillController.php', 'اضافة فاتورة مبيعات', '141', '0', null, '0', null, null,'', '0','1','1','141','1','2024-12-12 18:35:20','0','0');
UPDATE client SET  inUse = 0 where clientid = 1312;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 31362;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R2797', '149210', '1', '13910', '1', '140', '140', '0', '', '1', '2024-12-12 18:56:33', '13910', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','31362-1,','1','1','0','0','140','140','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 = 545239;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (13910, '2024-12-12', 140, 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+140, 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-12', 140, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+140, 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 = '2', userid = '101', storedetaildate = '2024-12-12 18:56:33' WHERE storedetailid = '13909';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('13910', '1', '1', '1', '149210', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '101', '2024-12-12 18:56: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', '149210', '17', '10291', '1', '1', '1', '0', '', '1', '2024-12-12 18:56:33', '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 = 91 where clientid = 1312;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 141, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+141, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1312, '2024-12-12', 141, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+141, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 141, 270, 270
                    , 270, 270, 270, 270, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+141, 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 0675b10c82ec74 and sellbillId = 149210 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245934
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245934 -clientdebtchangeId = 245936
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:26:43";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 18:56:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 18:56:43', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:26:52";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 18:56:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 18:56:52', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:27:05";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 18:57:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 18:57:05', '2', 'add', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =1312
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(1312,@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 ('1312','47.00','47','1','تسوية عجز عميل بالخصم','-1', '0', '2024-12-12 18:57:05', '2', 'clientDeficitController.php', '', '47', '0', null, '0', null, null,'', '0','1','1','47','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12', userid = '2' WHERE clientid = '1312';
UPDATE client SET  inUse = 0 where clientid = 1312;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =1312 ,id=245937
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:27:06";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 18:57:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 18:57:06', '2', 'sucess', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:27:07";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 18:57:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 18:57:07', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:27:44";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 18:57:44", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 18:57:44', '9', '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 ('اسلام  محمد' , '', '', '', '0', '', '0', '2024-12-12 19:02:10', '9', '0','','0','','-10','0','10000',',-20,','-1','0','.','0','0','.','2024-12-12','0','0','','0','0','0','','','0','0','','','','','','','','','','-1','');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('10686', '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 ('10686','0','0','0','إضافة عميل جديد','10686', '0', '2024-12-12 19:02:10', '9', 'clientController.php', '', '0', '0', null, '0', null, null,'', '0','1','1','0','1','','0','0');
INSERT INTO accountstree (name, customName, customNameEn, nameEn, parent, accountNature, theValue, theOrder, layingOrder, reportid, listId, notes, itemfrom, itemtype, itemtype2, itemtype3, userid, del, sysdate) VALUES ('اسلام  محمد', 'اسلام  محمد', 'اسلام  محمد', 'اسلام  محمد', '58', '0', '0', '0', '', '0', '0', '', '0', '3', '1', '', '9', '0', '2024-12-12 19:02:10');
UPDATE client SET clientname = 'اسلام  محمد', clientaddress = '', clientphone = '', clientmobile = '', clientdebt = '0.00', clientdetails = '', conditions = '0', clientdate = '2024-12-12', userid = '9'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '.',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0', taxnumber='', password='',clientTypeForTree='0',treeId='12432',husbandNameObgy='',txtNameE='',facility='',delegate='',txtemail='',commercial='',valtaxnumber='',clientaddress2='',country='',delegateid='-1',datecustomeraccount='0000-00-00' WHERE clientid = '10686';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:34:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:04:01", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:04: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-12 15:34:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:04:25", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:04:25', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b17817dd14
-- ----------------------------------------------------------------------------------------------------

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-12 19:04:01', '0675b17817dd14', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-12 19:04:26', '', '9', '0', 'نقدي', '1', '0', '3', '24', 'نقدي', '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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149211', '0', '2024-12-12 19:04:26', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 19:04:01','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', '149211', '5', '16316', '1', '300', '300', '0', '', '1', '2024-12-12 19:04:26', '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 = 545241;
 INSERT INTO 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-12', 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-12', 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 = '25', userid = '9', storedetaildate = '2024-12-12 19:04:26' WHERE storedetailid = '16315';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16316', '1', '1', '1', '149211', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '9', '2024-12-12 19:04:26','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '20970',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('20670','300', '0', '1', 'اضافة فاتورة مبيعات', '149211', '20970', '2024-12-12 19:04:26', '9',  '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-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 300, 225, 225
                    , 225, 225, 225, 225, 225, 225)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, netSellCostBuyPrice = netSellCostBuyPrice+225
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+225
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+225
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+225
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+225
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+225
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+225
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+225;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b17817dd14 and sellbillId = 149211 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:34:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:04:26", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:04:26', '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 userid = 101;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:34:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:04:51", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 19:04:51', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:34:56";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:04:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 19:04:56', '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-12 15:34:56";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:34:58";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:04:58", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:04:58', '9', 'showDetail', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149211');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:35:04";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:05:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-12 19:05:04', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientdebt.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:35:05";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:05:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-12 19:05:05', '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-12 15:35:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:05:15", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:05:15', '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-12 15:35:24";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:05:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-12 19:05:24', '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-12 15:35:31";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:05:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-12 19:05:31', '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-12 15:35:37";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:05:37", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientdebt.php', '2024-12-12 19:05: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-12 15:35:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:05:38", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:05:38', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b1608eeabc
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(10686,@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-12 18:57:44', '0675b1608eeabc', '10686', '0.00', '1200', '0', '1', '1200.00', '1200', '0', '1200', '1', '2024-12-12 19:05:38', '', '9', '0', 'اسلام  محمد', '1', '1', '3', '74', 'اسلام  محمد', '3' ,'0','','','','','-1','0','0','0','0','0','1200','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1200', userid = '9' WHERE clientid = '10686';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10686','0.00','1200','0','اضافة فاتورة مبيعات','149212', '1200', '2024-12-12 19:05:38', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1200', '0', null, '0', null, null,'', '0','1','1','1200','1','2024-12-12 18:57:44','0','0');
UPDATE client SET  inUse = 0 where clientid = 10686;
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', '149212', '14', '16204', '1', '610', '610', '0', '', '1', '2024-12-12 19:05:39', '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 = 545242;
 INSERT INTO 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-12', 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-12', 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 = '-6', userid = '9', storedetaildate = '2024-12-12 19:05:39' WHERE storedetailid = '16203';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16204', '1', '1', '1', '149212', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-5', '-6', '9', '2024-12-12 19:05:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35624;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('490','H1588', '149212', '14', '16168', '1', '580', '580', '0', '', '1', '2024-12-12 19:05:39', '16168', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35624-1,','1','1','0','0','580','580','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 = 545243;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16168, '2024-12-12', 580, 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+580, 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-12', 580, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0, 490, 490, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+580, 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 = '9', storedetaildate = '2024-12-12 19:05:39' WHERE storedetailid = '16167';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16168', '1', '1', '1', '149212', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8', '7', '9', '2024-12-12 19:05:39','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('0','10291', '149212', '17', '10291', '1', '10', '10', '0', '', '1', '2024-12-12 19:05:39', '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 = 74 where clientid = 10686;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1200, 990, 990
                    , 1595, 990, 1595, 990
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,990, 2200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+990
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+990, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1595
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+990, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1595
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+990
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+990
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10686, '2024-12-12', 1200, 990, 990
                    , 1595, 990, 1595, 990
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,990, 2200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+990
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+990, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1595
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+990, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1595
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+990
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+990
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1200, 990, 990
                    , 1595, 990, 1595, 990, 990, 2200)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1200, netSellCostBuyPrice = netSellCostBuyPrice+990
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+990
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1595
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+990
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1595
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+990
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+990
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2200;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b1608eeabc and sellbillId = 149212 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:35:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:05:39", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:05:39', '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-12 15:36:11";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:06:11", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 19:06:11', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE userid = 101;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:36:16";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:06:16", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:06:16', '9', 'showDetail', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149211');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:36:43";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:06:43", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 19:06:43', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE userid = 101;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:37:46";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:07:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:07:46', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:39:15";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 19:09:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 19:09:15', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:40:34";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:10:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 19:10:34', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:41:43";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:11:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:11:43', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:41:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:11:47", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:11:47', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b17cb827d6
-- ----------------------------------------------------------------------------------------------------

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-12 19:05:15', '0675b17cb827d6', '1', '0.00', '0', '10', '1', '610.00', '600', '600', '0', '1', '2024-12-12 19:11:47', '', '9', '0', 'نقدي', '1', '0', '3', '73', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','600','0','','0','0','600','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149213', '0', '2024-12-12 19:11:47', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '600', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 19:05:15','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', '149213', '14', '15622', '1', '610', '610', '0', '', '1', '2024-12-12 19:11:47', '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 = 545245;
 INSERT INTO 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-12', 600, 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+600, 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-12', 600, 500, 500
                    , 501, 500, 501, 425.29
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 509, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, 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 = '23', userid = '9', storedetaildate = '2024-12-12 19:11:47' WHERE storedetailid = '15621';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15622', '1', '1', '1', '149213', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24', '23', '9', '2024-12-12 19:11:47','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '21570',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('20970','600', '0', '1', 'اضافة فاتورة مبيعات', '149213', '21570', '2024-12-12 19:11:47', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 73 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 600, 500, 500
                    , 501, 500, 501, 425.29
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,500, 509, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, 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 (1, '2024-12-12', 600, 500, 500
                    , 501, 500, 501, 425.29
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,500, 509, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, 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, 600, 500, 500
                    , 501, 500, 501, 425.29, 500, 509)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+600, 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 0675b17cb827d6 and sellbillId = 149213 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:41:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:11:48", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:11:48', '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-12 15:42:31";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:12:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:12:31', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:43:05";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:13:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:13:05', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:44:30";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:14:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 19:14:30', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:48:25";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 19:18:25", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 19:18:25', '2', 'show', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:50:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:20:31", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 19:20:31', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:50:46";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 19:20:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 19:20:46', '2', 'add', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245941
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245941 -clientdebtchangeId = 245942
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:50:47";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 19:20:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 19:20:47', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:51:00";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:21:00", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:21:00', '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-12 15:52:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:22:51", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 19:22:51', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:53:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:23:09", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:23:09', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:53:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:23:22", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:23:22', '9', '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-12 15:53:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:23:29", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:23:29', '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-12 15:54:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:24:30", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:24:30', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b1b7c7189e
-- ----------------------------------------------------------------------------------------------------

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-12 19:21:00', '0675b1b7c7189e', '1', '0.00', '0', '0', '1', '340.00', '340', '340', '0', '1', '2024-12-12 19:24:31', '', '9', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','340','0','','0','0','340','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149214', '0', '2024-12-12 19:24:31', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '340', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 19:21:00','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 20382;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1037', '149214', '14', '9406', '1', '340', '340', '0', '', '1', '2024-12-12 19:24:31', '9406', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','20382-1,','1','1','0','0','340','340','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 = 545246;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (9406, '2024-12-12', 340, 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+340, 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-12', 340, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '5', userid = '9', storedetaildate = '2024-12-12 19:24:31' WHERE storedetailid = '9405';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('9406', '1', '1', '1', '149214', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '9', '2024-12-12 19:24:31','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '21910',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('21570','340', '0', '1', 'اضافة فاتورة مبيعات', '149214', '21910', '2024-12-12 19:24:31', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 340, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 340, 270, 270
                    , 270, 270, 270, 270
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340, sellCostBuyPrice =sellCostBuyPrice+270
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+270, sellCostMeanBuyPrice = sellCostMeanBuyPrice+270
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+270, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+270
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+270
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 340, 270, 270
                    , 270, 270, 270, 270, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+340, 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 0675b1b7c7189e and sellbillId = 149214 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:54:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:24:31", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:24:31', '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-12 15:54:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:24:41", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 19:24:41', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE userid = 2;
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:54:52";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:24:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 19:24:52', '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-12 15:54:52";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:54:53";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:24:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 19:24:53', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/index.php');
UPDATE product SET lastbuyprice=productBuyPrice,lastbuyprice_withDiscount=productBuyPrice,meanbuyprice=productBuyPrice,meanbuyprice_withDiscount=productBuyPrice where lastbuyprice is null;
DROP PROCEDURE IF EXISTS generateParcodes;;

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

        ALTER TABLE availableparcode ENGINE = MyISAM;

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

        ALTER TABLE availableparcode ENGINE = InnoDB;
    end

;
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
DROP PROCEDURE IF EXISTS saveInUse;;

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

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


;
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

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


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



START TRANSACTION;


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

	IF n > 0 THEN


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

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

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

End;
;;

;
DROP PROCEDURE IF EXISTS supplierInUse;;

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

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

END

;
DROP PROCEDURE IF EXISTS storedetailInUse;;

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

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


;
DROP PROCEDURE IF EXISTS sizeColorStoredetailInUseSP;;

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

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


;
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:54:54";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:54:59";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:24:59", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:24:59', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:55:00";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:25:00", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:25:00', '9', 'showDetail', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149214');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:55:11";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:25:11", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:25:11', '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-12 15:55:15";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:25:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:25:15', '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-12 15:55:24";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:25:24", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:25:24', '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-12 15:56:03";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:26:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 19:26:03', '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-12 15:56:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:26:15", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:26:15', '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-12 15:56:20";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:26:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 19:26:20', '2', 'edit', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=edit&id=10686');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:56:26";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:26:26", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 19:26:26', '2', 'update', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=update');
UPDATE tamweenclientdetail SET clientid = '10686', noOfPersonsTamween = '0', noOfPersonsDa3m = '0', cardNum = '', cardPassword = '' WHERE id = '10686';
UPDATE accountstree SET name = 'اسلام  محمد ب', customName = 'اسلام  محمد ب', customNameEn = 'اسلام  محمد', nameEn = 'اسلام  محمد', parent = '58', accountNature = '0', theValue = '0.00', theOrder = '0', layingOrder = '', reportid = '1', listId = '0', notes = '', itemfrom = '0', itemtype = '3', itemtype2 = '1', itemtype3 = '', userid = '2', del = '0', sysdate = '2024-12-12 19:26:26' WHERE id = '12432';
UPDATE client SET clientname = 'اسلام  محمد ب', clientaddress = '', clientphone = '', clientmobile = '', clientdetails = '', conditions = '0', clientdate = '2024-12-12 19:26:26', userid = '9'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '0' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '2',inUse = '0',card_number = '0',file_faida = '',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',postponeDays='0',taxnumber='', password='',clientTypeForTree='0',treeId='12432',clientaddress2='',country='',delegateid='74' WHERE clientid = '10686';
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:56:26";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:26:26", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 19:26:26', '2', 'sucess', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=sucess');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:56:28";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:26:28", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 19:26:28', '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-12 15:56:32";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:26:32", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:26:32', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b1cb77735e
-- ----------------------------------------------------------------------------------------------------

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-12 19:26:15', '0675b1cb77735e', '1', '0.00', '0', '0', '1', '170.00', '170', '170', '0', '1', '2024-12-12 19:26:32', '', '9', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','170','0','','0','0','170','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149215', '0', '2024-12-12 19:26:32', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '170', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 19:26:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 33857;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06533', '149215', '5', '14932', '1', '170', '170', '0', '', '1', '2024-12-12 19:26:32', '14932', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','33857-1,','1','1','0','0','170','170','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 = 545247;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14932, '2024-12-12', 170, 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+170, 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-12', 170, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+250
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '4', userid = '9', storedetaildate = '2024-12-12 19:26:32' WHERE storedetailid = '14931';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14932', '1', '1', '1', '149215', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '9', '2024-12-12 19:26:32','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22080',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('21910','170', '0', '1', 'اضافة فاتورة مبيعات', '149215', '22080', '2024-12-12 19:26:32', '9',  '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-12', 170, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, 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-12', 170, 250, 250
                    , 250, 250, 250, 250
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+170, 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, 170, 250, 250
                    , 250, 250, 250, 250, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+170, 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 0675b1cb77735e and sellbillId = 149215 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:56:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:26:33", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:26:33', '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-12 15:56:58";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 19:26:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 19:26:58', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:57:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:27:51", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:27:51', '9', 'addsellBill', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addsellBill&billnameid=5');
update user set blockedByLimits = 0;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:58:08";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:28:08", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 19:28:08', '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-12 15:58:09";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:58:10";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:28:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('index.php', '2024-12-12 19:28: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-12 15:58:10";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:58:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:28:12", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:28:12', '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-12 15:58:13";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:28:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 19:28: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-12 15:58:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:28:15", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:28:15', '9', '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-12 15:58:26";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:28:26", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:28:26', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b1d2f5a255
-- ----------------------------------------------------------------------------------------------------

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-12 19:28:15', '0675b1d2f5a255', '1', '0.00', '0', '0', '1', '200', '200', '-200', '0', '1', '2024-12-12 19:28:26', '', '9', '0', 'نقدي','1', '0', '5', '3', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-200','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16744', '0', '2024-12-12 19:28:26', '9', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '200', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 19:28:15','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('140.00', '07126', '16744', '5', '16155', '1', '200', '200', '0', '', '1', '0', '16155', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','200','200','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 = 21904;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16155, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 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+200, 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 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+200, 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 = '1', userid = '9', storedetaildate = '2024-12-12 19:28:26' WHERE storedetailid = '16154';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16155', '1', '1', '0', '16744', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '0', '1', '9', '2024-12-12 19:28:26','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '21880',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('22080','-200', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16744', '21880', '2024-12-12 19:28:26', '9',  '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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 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+200, returnSellCostBuyPrice = returnSellCostBuyPrice+140, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+140
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+140, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+140
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+140
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+140
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+140
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+140;
 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 200, 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+200, returnSellCostBuyPrice = returnSellCostBuyPrice+140, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+140
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+140, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+140
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+140
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+140
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+140
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+140;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -200, -140, -140
                    , -140, -140, -140, -140, -140, -140)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-200, netSellCostBuyPrice = netSellCostBuyPrice+-140
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-140
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-140
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-140
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-140
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-140
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-140
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-140;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b1d2f5a255 and sellbillId = 16744 and returnsellbillId = 16744
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:58:27";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:28:27", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:28:27', '9', '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-12 15:58:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:28:30", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:28: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-12 15:58:32";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:28:32", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:28:32', '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-12 15:58:33";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:28:33", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 19:28:33', '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-12 15:58:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:28:47", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:28:47', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b1d3f0ae30
-- ----------------------------------------------------------------------------------------------------

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-12 19:28:31', '0675b1d3f0ae30', '1', '0.00', '0', '0', '1', '300.00', '300', '300', '0', '1', '2024-12-12 19:28:48', '', '9', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','300','0','','0','0','300','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149216', '0', '2024-12-12 19:28:48', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '300', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 19:28:31','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', '149216', '5', '16245', '1', '300', '300', '0', '', '1', '2024-12-12 19:28:48', '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 = 545248;
 INSERT INTO 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-12', 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-12', 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 = '9', storedetaildate = '2024-12-12 19:28:48' WHERE storedetailid = '16244';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16245', '1', '1', '1', '149216', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '9', '2024-12-12 19:28:48','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22180',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('21880','300', '0', '1', 'اضافة فاتورة مبيعات', '149216', '22180', '2024-12-12 19:28:48', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 300, 240, 240
                    , 240, 240, 240, 240, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+300, 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 0675b1d3f0ae30 and sellbillId = 149216 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:58:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:28:48", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:28:48', '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-12 15:59:07";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:29:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 19:29:07', '2', 'edit', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=edit&id=10686');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:59:21";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:29:21", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 19:29:21', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 15:59:36";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:29:36", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:29:36', '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-12 15:59:48";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:29:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:29:48', '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-12 16:00:02";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:30:02", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:30:02', '2', 'editsellBill', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editsellBill&sellbillid=149212');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:00:39";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:30:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:30:39', '2', 'update', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=update');
BEGIN;

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


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

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 149212;
UPDATE sellbill SET  sellbillsysdate = '2024-12-12 19:30:39', userid = '9',delbyuserid = '2', conditions = '1'  WHERE sellbillid = '149212';
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35973;
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 1105.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 1105.00
        , lastbuyprice_withTax = 500, meanbuyprice_withTax = 1710, lastbuyprice_withDiscountAndTax = 500
                where sellbilldetailid = 545242;
 INSERT INTO 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-12', 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-12', 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 = '-5', userid = '2', storedetaildate = '2024-12-12 19:30:39' WHERE storedetailid = '16203';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16204', '1', '1', '0', '149212', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-6', '-5', '2', '2024-12-12 18:57:44','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-1 where id = 35624;
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 = 545243;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16168, '2024-12-12', 580, 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-580, 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-12', 580, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0, 490, 490, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-580, 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 = '8', userid = '2', storedetaildate = '2024-12-12 19:30:39' WHERE storedetailid = '16167';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16168', '1', '1', '0', '149212', 'تعديل فاتورة مبيعات', 'sellbillController.php', '7', '8', '2', '2024-12-12 18:57:44','0','0');
CALL clientInUse(10686,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '0', userid = '2' WHERE clientid = '10686';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('10686','1200.00','1200.00','1','تعديل فاتورة مبيعات','149212', '0', '2024-12-12 18:57:44', '2', 'sellbillController.php', 'تعديل فاتورة مبيعات', '1200', '0', null, '0', null, null,'', '0','1','1','1200','1','2024-12-12 18:57:44','0','0');
UPDATE client SET  inUse = 0 where clientid = 10686;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1200, 990, 990
                    , 1595, 990, 1595, 990
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,990, 2200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1200, sellCostBuyPrice =sellCostBuyPrice-990
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-990, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1595
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-990, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1595
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-990
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-990
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-2200
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (10686, '2024-12-12', 1200, 990, 990
                    , 1595, 990, 1595, 990
                    , 0, 0, 0, 0
                    , 0, 0, 0, 990, 2200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-1200, sellCostBuyPrice =sellCostBuyPrice-990
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-990, sellCostMeanBuyPrice = sellCostMeanBuyPrice-1595
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-990, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-1595
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-990
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-990
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-2200
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1200, 990, 990
                    , 1595, 990, 1595, 990, 990, 2200)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-1200, netSellCostBuyPrice = netSellCostBuyPrice-990
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-990
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-1595
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-990
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-1595
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-990
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax-990
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax-2200;

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


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

COMMIT;
BEGIN;
CALL clientInUse(689,@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-12 18:57:44', '0675b1608eeabc', '689', '0.00', '1200', '20', '1', '1220', '1200', '0', '1200', '1', '2024-12-12 18:57:44', '', '2', '0', 'اسلام محمد', '1', '1', '3', '74', 'اسلام محمد', '3', '149212', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00','0','-1','2024-12-12','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1200', userid = '2' WHERE clientid = '689';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('689','0.00','1200','0','اضافة فاتورة مبيعات (معدله)','149217', '1200', '2024-12-12 19:30:40', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '1200', '0', null, '0', null, null,'', '0','1','1','1200','1','2024-12-12 18:57:44','0','0');
UPDATE client SET  inUse = 0 where clientid = 689;
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', '149217', '14', '16204', '1', '610', '610', '0', '', '0', '2024-12-12 19:30:40', '16204', '0.00', '-1', '1','0','','','0','0','0','0','0','0','0','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 = 545249;
 INSERT INTO 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-12', 600, 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+600, 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-12', 600, 500, 500
                    , 1105, 500, 1105, 500
                    , 0, 0, 0, 0
                    , 0, 0, 0, 500, 1710, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+600, 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 = '-6', userid = '2', storedetaildate = '2024-12-12 19:30:40' WHERE storedetailid = '16203';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16204', '1', '1', '1', '149217', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '-5', '-6', '2', '2024-12-12 19:30:40','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35624;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('490','H1588', '149217', '14', '16168', '1', '600', '600', '0', '', '0', '2024-12-12 19:30:40', '16168', '0.00', '-1', '1','0','','','0','0','0','0','0','0','0','0','','35624-1,','1','1','0','0','600','600','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 = 545250;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16168, '2024-12-12', 590.16393442623, 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+590.16393442623, 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-12', 590.16393442623, 490, 490
                    , 490, 490, 490, 490
                    , 0, 0, 0, 0
                    , 0, 0, 0, 490, 490, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+590.16393442623, 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 = '2', storedetaildate = '2024-12-12 19:30:40' WHERE storedetailid = '16167';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16168', '1', '1', '1', '149217', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '8', '7', '2', '2024-12-12 19:30: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', '149217', '17', '10291', '1', '10', '10', '0', '', '0', '2024-12-12 19:30:40', '10291', '0.00', '1', '1','0','','','0','0','0','0','0','0','0','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-12', 1200, 990, 990
                    , 1595, 990, 1595, 990
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,990, 2200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+990
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+990, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1595
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+990, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1595
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+990
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+990
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (689, '2024-12-12', 1200, 990, 990
                    , 1595, 990, 1595, 990
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,990, 2200, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1200, sellCostBuyPrice =sellCostBuyPrice+990
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+990, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1595
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+990, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1595
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+990
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+990
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+2200
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1200, 990, 990
                    , 1595, 990, 1595, 990, 990, 2200)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1200, netSellCostBuyPrice = netSellCostBuyPrice+990
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+990
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1595
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+990
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1595
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+990
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+990
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+2200;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 149212 and newid=149217 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:00:41";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:30:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:30:41', '2', 'editprint', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=editprint&id=149217');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:00:58";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 19:30:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 19:30:58', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:01:39";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 19:31:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 19:31:39', '2', 'add', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245949
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:01:40";
UPDATE user SET loginip = "192.168.1.59", lastactivetime = "2024-12-12 19:31:40", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 19:31:40', '2', '', '192.168.1.59', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:05:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:35:18", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:35:18', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b1c1223eb4
-- ----------------------------------------------------------------------------------------------------

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-12 19:23:30', '0675b1c1223eb4', '1', '0.00', '0', '0', '1', '310.00', '310', '310', '0', '1', '2024-12-12 19:35:18', '', '9', '0', 'نقدي', '1', '0', '3', '73', 'نقدي', '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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149218', '0', '2024-12-12 19:35:18', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '310', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 19:23:30','0','0');
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', '149218', '5', '16331', '1', '310', '310', '0', '', '1', '2024-12-12 19:35:18', '16331', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35986-1,','1','1','0','0','310','310','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 = 545252;
 INSERT INTO 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-12', 310, 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+310, 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-12', 310, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, 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 = '44', userid = '9', storedetaildate = '2024-12-12 19:35:18' WHERE storedetailid = '16330';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16331', '1', '1', '1', '149218', 'اضافة فاتورة مبيعات', 'sellbillController.php', '45', '44', '9', '2024-12-12 19:35:18','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '22490',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('22180','310', '0', '1', 'اضافة فاتورة مبيعات', '149218', '22490', '2024-12-12 19:35:18', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 73 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 310, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+240
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+240
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+240
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 310, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+310, 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, 310, 240, 240
                    , 240, 240, 240, 240, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+310, 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 0675b1c1223eb4 and sellbillId = 149218 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:05:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:35:18", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:35:18', '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-12 16:10:00";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:40:00", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 19:40: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-12 16:10:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:40:06", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:40:06', '9', 'showDetail', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149218');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:10:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:40:20", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:40:20', '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-12 16:11:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:41:13", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:41:13', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b2004cbd09
-- ----------------------------------------------------------------------------------------------------

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-12 19:40:20', '0675b2004cbd09', '1', '0.00', '0', '0', '1', '750.00', '750', '750', '0', '1', '2024-12-12 19:41:13', '', '9', '0', 'نقدي', '1', '0', '3', '73', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','750','0','','0','0','750','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149219', '0', '2024-12-12 19:41:13', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '750', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 19:40:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35856;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('370','07180', '149219', '5', '16264', '1', '450', '450', '0', '', '1', '2024-12-12 19:41:13', '16264', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35856-1,','1','1','0','0','450','450','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 = 545253;
 INSERT INTO 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-12', 450, 400, 400
                    , 387, 400, 387, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 400, 387, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+387
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+387
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+387
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 450, 400, 400
                    , 387, 400, 387, 385
                    , 0, 0, 0, 0
                    , 0, 0, 0, 400, 387, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+387
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+387
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+385
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+400
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+387
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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 = '9', storedetaildate = '2024-12-12 19:41:13' WHERE storedetailid = '16263';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16264', '1', '1', '1', '149219', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22', '21', '9', '2024-12-12 19:41:13','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35993;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','07250', '149219', '5', '16338', '1', '300', '300', '0', '', '1', '2024-12-12 19:41:13', '16338', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35993-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 545254;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16338, '2024-12-12', 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-12', 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 = '9', storedetaildate = '2024-12-12 19:41:13' WHERE storedetailid = '16337';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16338', '1', '1', '1', '149219', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '9', '2024-12-12 19:41:13','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '23240',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('22490','750', '0', '1', 'اضافة فاتورة مبيعات', '149219', '23240', '2024-12-12 19:41:13', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 73 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 750, 640, 640
                    , 627, 640, 627, 625
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,640, 627, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+627
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+627
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+625
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+640
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+627
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 750, 640, 640
                    , 627, 640, 627, 625
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,640, 627, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+640
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+640, sellCostMeanBuyPrice = sellCostMeanBuyPrice+627
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+640, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+627
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+625
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+640
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+627
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 750, 640, 640
                    , 627, 640, 627, 625, 640, 627)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+750, netSellCostBuyPrice = netSellCostBuyPrice+640
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+640
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+627
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+640
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+627
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+625
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+640
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+627;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b2004cbd09 and sellbillId = 149219 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b203ab9ab0
-- ----------------------------------------------------------------------------------------------------

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-12 19:41:14', '0675b203ab9ab0', '1', '0.00', '0', '0', '1', '720.00', '720', '720', '0', '1', '2024-12-12 19:42:50', '', '9', '0', 'نقدي', '1', '0', '3', '26', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','720','0','','0','0','720','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149220', '0', '2024-12-12 19:42:50', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '720', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 19:41:14','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35824;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('240','07174', '149220', '5', '16240', '1', '300', '300', '0', '', '1', '2024-12-12 19:42:50', '16240', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35824-1,','1','1','0','0','300','300','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
        , lastbuyprice_withTax = 240, meanbuyprice_withTax = 240, lastbuyprice_withDiscountAndTax = 240
                where sellbilldetailid = 545255;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16240, '2024-12-12', 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-12', 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 = '8', userid = '9', storedetaildate = '2024-12-12 19:42:50' WHERE storedetailid = '16239';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16240', '1', '1', '1', '149220', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9', '8', '9', '2024-12-12 19:42:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35573;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07106', '149220', '5', '16135', '1', '420', '420', '0', '', '1', '2024-12-12 19:42:50', '16135', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35573-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 = 545256;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16135, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 420, 360, 360
                    , 360, 360, 360, 360
                    , 0, 0, 0, 0
                    , 0, 0, 0, 360, 360, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+360
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+360
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+360
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '11', userid = '9', storedetaildate = '2024-12-12 19:42:50' WHERE storedetailid = '16134';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16135', '1', '1', '1', '149220', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '9', '2024-12-12 19:42:50','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '23960',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('23240','720', '0', '1', 'اضافة فاتورة مبيعات', '149220', '23960', '2024-12-12 19:42:50', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 26 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 720, 600, 600
                    , 600, 600, 600, 600
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,600, 600, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+600
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+600
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 720, 600, 600
                    , 600, 600, 600, 600
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,600, 600, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+720, sellCostBuyPrice =sellCostBuyPrice+600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+600
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+600
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 720, 600, 600
                    , 600, 600, 600, 600, 600, 600)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+720, netSellCostBuyPrice = netSellCostBuyPrice+600
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+600
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+600
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+600
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+600
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+600
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+600
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+600;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b203ab9ab0 and sellbillId = 149220 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:12:50";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:42:50", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:42:50', '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-12 16:13:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:43:24", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:43:24', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b205f15f41
-- ----------------------------------------------------------------------------------------------------

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-12 19:41:51', '0675b205f15f41', '1', '0.00', '0', '0', '1', '670.00', '670', '670', '0', '1', '2024-12-12 19:43:24', '', '9', '0', 'نقدي', '1', '0', '3', '73', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','670','0','','0','0','670','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149221', '0', '2024-12-12 19:43:24', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '670', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 19:41:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35869;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07190', '149221', '5', '16273', '1', '420', '420', '0', '', '1', '2024-12-12 19:43:24', '16273', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35869-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 = 545257;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16273, '2024-12-12', 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-12', 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 = '11', userid = '9', storedetaildate = '2024-12-12 19:43:24' WHERE storedetailid = '16272';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16273', '1', '1', '1', '149221', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12', '11', '9', '2024-12-12 19:43:24','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', '149221', '5', '16369', '1', '250', '250', '0', '', '1', '2024-12-12 19:43:24', '16369', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36095-1,','1','1','0','0','250','250','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 = 545258;
 INSERT INTO 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-12', 250, 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+250, 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-12', 250, 210, 210
                    , 210, 210, 210, 210
                    , 0, 0, 0, 0
                    , 0, 0, 0, 210, 210, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, 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 = '13', userid = '9', storedetaildate = '2024-12-12 19:43:24' WHERE storedetailid = '16368';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16369', '1', '1', '1', '149221', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14', '13', '9', '2024-12-12 19:43:24','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24630',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('23960','670', '0', '1', 'اضافة فاتورة مبيعات', '149221', '24630', '2024-12-12 19:43:24', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 73 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 670, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,575, 575, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+670, 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-12', 670, 575, 575
                    , 575, 575, 575, 575
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,575, 575, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+670, 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, 670, 575, 575
                    , 575, 575, 575, 575, 575, 575)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+670, 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 0675b205f15f41 and sellbillId = 149221 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:13:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:43:25", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:43:25', '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-12 16:15:00";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:45:00", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:45:00', '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-12 16:16:30";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:46:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:46:30', '2', 'addAndRetuen', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b211ccd6a0
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(2675,@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-12 19:45:00', '0675b211ccd6a0', '2675', '3810.00', '10330', '0', '1', '6520.00', '6520', '0', '6520', '1', '2024-12-12 19:46:30', '', '2', '0', 'محل الملكة', '2', '1', '3', '91', 'محل الملكة', '26' ,'0','','','','','-1','0','0','0','0','0','6520','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '10330', userid = '2' WHERE clientid = '2675';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('2675','3810.00','6520','0','اضافة فاتورة مبيعات','149222', '10330', '2024-12-12 19:46:30', '2', 'sellbillController.php', 'اضافة فاتورة مبيعات', '6520', '0', null, '0', null, null,'', '0','1','1','6520','1','2024-12-12 19:45:00','0','0');
UPDATE client SET  inUse = 0 where clientid = 2675;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+13 where id = 36105;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 36268;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','07240', '149222', '5', '16359', '15', '240', '3600', '0', '', '1', '2024-12-12 19:46:30', '16359', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36105-13,36268-2,','1','1','0','0','240','3600','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 = 545259;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16359, '2024-12-12', 3600, 3525, 3525
                    , 3525, 3525, 3525, 3525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 15, 0, 3525, 3525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3600, sellCostBuyPrice =sellCostBuyPrice+3525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+15
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 3600, 3525, 3525
                    , 3525, 3525, 3525, 3525
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3525, 3525, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3600, sellCostBuyPrice =sellCostBuyPrice+3525
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3525, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3525
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3525, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3525
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+3525
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+3525
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+3525
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 19:46:30' WHERE storedetailid = '16358';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16359', '1', '15', '1', '149222', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28', '13', '2', '2024-12-12 19:46:30','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 34670;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+7 where id = 35342;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1429', '149222', '14', '15737', '10', '290', '2900', '0', '', '1', '2024-12-12 19:46:30', '15737', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','34670-3,35342-7,','1','1','0','0','290','2900','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 = 198, lastbuyprice_withDiscountAndTax = 260
                where sellbilldetailid = 545260;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (15737, '2024-12-12', 2900, 2600, 2600
                    , 2600, 2600, 2600, 2600
                    , 0, 0, 0, 0
                    , 0, 0, 0, 10, 0, 2600, 1980, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2900, sellCostBuyPrice =sellCostBuyPrice+2600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2600
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1980
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+10
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 2900, 2600, 2600
                    , 2600, 2600, 2600, 2600
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2600, 1980, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2900, sellCostBuyPrice =sellCostBuyPrice+2600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+2600
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+2600
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+1980
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = 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-12 19:46:30' WHERE storedetailid = '15736';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15737', '1', '10', '1', '149222', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13', '3', '2', '2024-12-12 19:46: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', '149222', '9', '2015', '1', '20', '20', '0', '', '1', '2024-12-12 19:46:30', '2015', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','','1','1','0','0','20','20','0','','0','0.00','0','0','0','0');
UPDATE client SET  delegateid = 91 where clientid = 2675;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 6520, 6125, 6125
                    , 6125, 6125, 6125, 6125
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,6125, 5505, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+6520, sellCostBuyPrice =sellCostBuyPrice+6125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+6125
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5505
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (2675, '2024-12-12', 6520, 6125, 6125
                    , 6125, 6125, 6125, 6125
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,6125, 5505, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+6520, sellCostBuyPrice =sellCostBuyPrice+6125
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+6125, sellCostMeanBuyPrice = sellCostMeanBuyPrice+6125
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+6125, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+6125
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+6125
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+6125
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+5505
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 6520, 6125, 6125
                    , 6125, 6125, 6125, 6125, 6125, 5505)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+6520, netSellCostBuyPrice = netSellCostBuyPrice+6125
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+6125
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+6125
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+6125
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+6125
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+6125
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+6125
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+5505;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b211ccd6a0 and sellbillId = 149222 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:16:31";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:46:31", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:46:31', '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-12 16:18:30";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:48:30", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:48:30', '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-12 16:18:41";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:48:41", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 19:48:41', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:18:43";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:48:43", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 19:48:43', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:18:44";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:48:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 19:48:44', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:21:39";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:51:39", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:51:39', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:22:04";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:52:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:52:04', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:22:19";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:52:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:52:20', '2', 'showDetail', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149154');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:22:42";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:52:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:52:42', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:22:46";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:52:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:52:46', '2', 'showDetail', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149027');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:23:29";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:53:29", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:53:29', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:23:34";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:53:34", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:53:34', '2', 'showDetail', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149187');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:23:48";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:53:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:53:48', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:23:53";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:53:53", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:53:53', '2', 'showDetail', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149178');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:24:20";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:54:20", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:54:20', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:24:27";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:54:27", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:54:27', '2', 'showDetail', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=147652');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:24:48";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:54:48", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:54:48', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:24:52";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:54:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:54:52', '2', 'showDetail', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=148879');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:24:56";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:54:56", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 19:54:56', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:25:06";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:55:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 19:55:06', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:25:10";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:55:10", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:55:10', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:25:14";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:55:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:55:14', '2', 'showDetail', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=147919');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:25:32";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:55:32", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:55:32', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:25:38";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:55:38", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:55:38', '2', 'showDetail', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=148157');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:25:55";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 19:55:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 19:55:55', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:26:09";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:56:09", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:56:09', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:26:13";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:56:13", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:56:13', '2', 'showDetail', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149034');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:26:47";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:56:47", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:56:47', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:26:51";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:56:51", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:56:51', '2', 'showDetail', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=145725');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:27:14";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:57:14", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 19:57:14', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:27:18";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 19:57:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:57:18', '2', 'showDetail', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=147637');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:27:44";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:57:44", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:57:44', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b1d51012ec
-- ----------------------------------------------------------------------------------------------------

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-12 19:28:49', '0675b1d51012ec', '1', '0.00', '0', '0', '1', '320.00', '320', '320', '0', '1', '2024-12-12 19:57:44', '', '9', '0', 'نقدي', '1', '0', '3', '4', 'نقدي', '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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149223', '0', '2024-12-12 19:57:44', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '320', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 19:28:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32990;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06512', '149223', '5', '14886', '1', '320', '320', '0', '', '1', '2024-12-12 19:57:44', '14886', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32990-1,','1','1','0','0','320','320','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 = 545262;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14886, '2024-12-12', 320, 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+320, 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-12', 320, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, 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 = '5', userid = '9', storedetaildate = '2024-12-12 19:57:44' WHERE storedetailid = '14885';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14886', '1', '1', '1', '149223', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '9', '2024-12-12 19:57:44','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24950',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('24630','320', '0', '1', 'اضافة فاتورة مبيعات', '149223', '24950', '2024-12-12 19:57:44', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 4 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 320, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, 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;
 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-12', 320, 335, 335
                    , 335, 335, 335, 335
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+320, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 320, 335, 335
                    , 335, 335, 335, 335, 0, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+320, netSellCostBuyPrice = netSellCostBuyPrice+335
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+335
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+335
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+335
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+335
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+335
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+0
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b1d51012ec and sellbillId = 149223 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:27:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 19:57:45", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 19:57:45', '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-12 16:31:09";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:01:09", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 20:01:09', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:31:27";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:01:27", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('salesreport.php', '2024-12-12 20:01:27', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/salesreport.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:32:04";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:02:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:02:05', '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-12 16:32:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:02:41", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:02:41', '9', '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-12 16:32:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:02:57", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:02:57', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b2541b51b7
-- ----------------------------------------------------------------------------------------------------

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-12 20:02:41', '0675b2541b51b7', '1', '0.00', '0', '0', '1', '650', '650', '-650', '0', '1', '2024-12-12 20:02:57', '', '9', '0', 'نقدي','1', '0', '5', '5', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-650','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','16745', '0', '2024-12-12 20:02:57', '9', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '650', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 20:02:41','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 ('535.00', 'H1622', '16745', '14', '16251', '1', '650', '650', '0', '', '1', '0', '16251', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','650','650','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 535.00 , meanbuyprice = 535.00, lastbuyprice_withDiscount = 535.00, meanbuyprice_withDiscount = 535.00
        , lastbuyprice_withTax = 535, meanbuyprice_withTax = 535, lastbuyprice_withDiscountAndTax = 535
                where returnsellbilldetailid = 21905;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16251, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 650, 535, 535, 535
                    , 535, 535, 535, 0, 1, 0, 0, 535, 535)
                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+650, returnSellCostBuyPrice = returnSellCostBuyPrice+535, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+535
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+535, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+535
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+535
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+535
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+535
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+535
                        , 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 650, 535, 535, 535
                    , 535, 535, 535, 0, 0, 535, 535)
                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+650, returnSellCostBuyPrice = returnSellCostBuyPrice+535, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+535
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+535, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+535
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+535
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+535
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+535
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+535;
UPDATE storedetail SET  productquantity = '12', userid = '9', storedetaildate = '2024-12-12 20:02:57' WHERE storedetailid = '16250';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16251', '1', '1', '0', '16745', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '11', '12', '9', '2024-12-12 20:02:57','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24300',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('24950','-650', '1', '1', 'اضافة فاتورة مردوات مبيعات', '16745', '24300', '2024-12-12 20:02:57', '9',  'returnsellbillController.php','1','','0');
UPDATE client SET  delegateid = 5 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 650, 535, 535, 535
                    , 535, 535, 535 ,0, 0, 535, 535)
                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+650, returnSellCostBuyPrice = returnSellCostBuyPrice+535, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+535
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+535, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+535
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+535
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+535
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+535
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+535;
 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 650, 535, 535, 535
                    , 535, 535, 535 ,0, 0, 535, 535)
                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+650, returnSellCostBuyPrice = returnSellCostBuyPrice+535, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+535
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+535, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+535
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+535
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+535
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+535
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+535;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -650, -535, -535
                    , -535, -535, -535, -535, -535, -535)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-650, netSellCostBuyPrice = netSellCostBuyPrice+-535
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-535
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-535
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-535
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-535
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-535
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-535
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-535;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b2541b51b7 and sellbillId = 16745 and returnsellbillId = 16745
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:32:58";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:02:58", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:02:58', '9', '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-12 16:37:01";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:07:01", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 20:07:01', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:37:05";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:07:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 20:07:05', '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-12 16:48:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:18:55", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 20:18:55', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:49:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:19:06", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 20:19:06', '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-12', '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 = '24250',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('24300.00','50', '1', '1', 'إضافة مصروف', '25627', '24250', '2024-12-12 20:19:06', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'رضوي', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25627';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:49:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:19:07", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 20:19: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-12 16:49:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:19:09", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 20:19: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-12 16:50:09";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 20:20:09", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 20:20:09', '2', '', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:50:19";
UPDATE user SET loginip = "192.168.1.16", lastactivetime = "2024-12-12 20:20:19", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 20:20:19', '2', 'show', '192.168.1.16', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:51:28";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:21:28", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 20:21:28', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:51:46";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:21:46", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:21:46', '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-12 16:51:55";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:21:55", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:21:55', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:52:03";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:22:03", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:22:03', '2', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=149206');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:52:06";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:22:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 20:22:06', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:52:19";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:22:19", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 20:22:19', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:52:22";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:22:22", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 20:22:22', '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-12 16:54:05";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:24:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 20:24:05', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:54:07";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:24:07", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 20:24:07', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:54:18";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:24:18", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 20:24:18', '2', 'add', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245957
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(518,@clientdebt,@clientname,@treeIdis);
UPDATE client SET  clientdebt = '85' , clientdate = '2024-12-12 20:24:18', userid = '2' WHERE clientid = '518';
UPDATE client SET  inUse = 0 where clientid = 518;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('518','585.00','500','1','ايصال تحصيل (( قبض من عميل ))','245957', '85', '2024-12-12 20:24:05', '2', 'clientPayedDeptController.php', '   ', '500', '0', null, '0', null, null,'', '-1','1','1','500','1','','3184','0');
UPDATE save SET  savecurrentvalue = '517989.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('517489.50','500', '0', '2', 'ايصال تحصيل (( قبض من عميل ))', '245957', '517989.5', '2024-12-12 20: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 ( '500', '500', '2024-12-12', '2', '0', '0', '2024-12-12 20:24:18','اضافة ايصال سداد للعميل نهي فوزي Z10','1','0','0','0','245957','clientPayedDeptController.php?do=show&id=245957');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('121767', '-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 ('121767', '-1', '500', '','0');
UPDATE accountstree SET name = '', customName = '', customNameEn = '', nameEn = '', parent = null, accountNature = '0', theValue = '-500', theOrder = null, layingOrder = '', reportid = '0', listId = '0', notes = '', itemfrom = null, itemtype = null, itemtype2 = null, itemtype3 = '', userid = null, del = null, sysdate = '' WHERE id = null;
UPDATE clientdebtchange SET clientid = '518', clientdebtchangebefore = '585.000', clientdebtchangeamount = '500.000', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '245957', clientdebtchangeafter = '85.000', clientdebtchangedate = '2024-12-12 20:24:05', userid = '2', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '500.00',discount='', reciptid='0', dailyentryid = '121767',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='500',saveConversionFactor='1',totalpayments='0' WHERE clientdebtchangeid = '245957';
COMMIT;

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

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

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =518
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(518,@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 ('518','85.00','85','1','تسوية عجز عميل بالخصم','-1', '0', '2024-12-12 20:24:31', '2', 'clientDeficitController.php', 'فرق', '85', '0', null, '0', null, null,'', '0','1','1','85','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12', userid = '2' WHERE clientid = '518';
UPDATE client SET  inUse = 0 where clientid = 518;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =518 ,id=245958
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245958
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =245958 -clientdebtchangeId = 245959
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:54:50";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:24:50", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 20:24:50', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:54:51";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:24:51", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 20:24:51', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientPayedDeptController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:55:44";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:25:44", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 20:25:44', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientReportsController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:55:52";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:25:52", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientReportsController.php', '2024-12-12 20:25:52', '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-12 16:55:58";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:25:58", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:25:58', '2', 'showDetail', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=showDetail&sellbillid=147637');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 16:58:32";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:28:32", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientController.php', '2024-12-12 20:28:32', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientController.php?do=show');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:03:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:33:24", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:33:24', '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-12 17:05:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:35:19", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:35:19', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b2c749e85a
-- ----------------------------------------------------------------------------------------------------

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-12 20:33:24', '0675b2c749e85a', '1', '0.00', '0', '5', '1', '545.00', '540', '540', '0', '1', '2024-12-12 20:35:19', '', '9', '0', 'نقدي', '1', '0', '3', '6', 'نقدي', '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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149224', '0', '2024-12-12 20:35:19', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '540', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 20:33:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 32992;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','06519', '149224', '5', '14890', '1', '245', '245', '0', '', '1', '2024-12-12 20:35:19', '14890', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','32992-1,','1','1','0','0','245','245','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 = 545263;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14890, '2024-12-12', 242.75229357798, 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+242.75229357798, 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-12', 242.75229357798, 235, 235
                    , 235, 235, 235, 235
                    , 0, 0, 0, 0
                    , 0, 0, 0, 0, 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+242.75229357798, sellCostBuyPrice =sellCostBuyPrice+235
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+235, sellCostMeanBuyPrice = sellCostMeanBuyPrice+235
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+235, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+235
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+235
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+0
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '9', storedetaildate = '2024-12-12 20:35:19' WHERE storedetailid = '14889';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14890', '1', '1', '1', '149224', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3', '2', '9', '2024-12-12 20:35:19','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35835;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','H1586', '149224', '14', '16157', '1', '300', '300', '0', '', '1', '2024-12-12 20:35:19', '16157', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35835-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 = 545264;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16157, '2024-12-12', 297.24770642202, 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+297.24770642202, 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-12', 297.24770642202, 230, 230
                    , 230, 230, 230, 230
                    , 0, 0, 0, 0
                    , 0, 0, 0, 230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+297.24770642202, 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 = '9', storedetaildate = '2024-12-12 20:35:19' WHERE storedetailid = '16156';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16157', '1', '1', '1', '149224', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6', '5', '9', '2024-12-12 20:35:19','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '24790',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('24250','540', '0', '1', 'اضافة فاتورة مبيعات', '149224', '24790', '2024-12-12 20:35:19', '9',  '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-12', 540, 465, 465
                    , 465, 465, 465, 465
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, sellCostBuyPrice =sellCostBuyPrice+465
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+465, sellCostMeanBuyPrice = sellCostMeanBuyPrice+465
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+465, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+465
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+465
                            , 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-12', 540, 465, 465
                    , 465, 465, 465, 465
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,230, 230, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+540, sellCostBuyPrice =sellCostBuyPrice+465
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+465, sellCostMeanBuyPrice = sellCostMeanBuyPrice+465
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+465, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+465
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+465
                            , 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, 540, 465, 465
                    , 465, 465, 465, 465, 230, 230)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+540, netSellCostBuyPrice = netSellCostBuyPrice+465
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+465
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+465
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+465
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+465
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+465
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+230
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+230;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b2c749e85a and sellbillId = 149224 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:05:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:35:20", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:35:20', '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-12 17:05:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:35:33", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 20:35:33', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:05:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:35:39", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 20:35:39', '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-12', '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 = '24740',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('24790.00','50', '1', '1', 'إضافة مصروف', '25628', '24740', '2024-12-12 20:35:39', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'مروان', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25628';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:05:39";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:35:39", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 20:35:39', '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-12 17:05:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:35:41", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 20:35:41', '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-12 17:07:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:37:18", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:37:18', '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-12 17:09:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:39:10", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:39:10', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b2d5ebd981
-- ----------------------------------------------------------------------------------------------------

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-12 20:37:18', '0675b2d5ebd981', '1', '0.00', '0', '0', '1', '900.00', '900', '900', '0', '1', '2024-12-12 20:39:11', '', '9', '0', 'نقدي', '1', '0', '3', '73', 'نقدي', '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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149225', '0', '2024-12-12 20:39:11', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '900', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 20:37: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', '149225', '14', '16340', '1', '500', '500', '0', '', '1', '2024-12-12 20:39:11', '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 = 545265;
 INSERT INTO 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-12', 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-12', 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 = '24', userid = '9', storedetaildate = '2024-12-12 20:39:11' WHERE storedetailid = '16339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16340', '1', '1', '1', '149225', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25', '24', '9', '2024-12-12 20:39:11','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35828;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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','R3321', '149225', '1', '16243', '1', '400', '400', '0', '', '1', '2024-12-12 20:39:11', '16243', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35828-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 = 545266;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16243, '2024-12-12', 400, 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+400, 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-12', 400, 340, 340
                    , 340, 340, 340, 340
                    , 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+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 = '38', userid = '9', storedetaildate = '2024-12-12 20:39:11' WHERE storedetailid = '16242';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16243', '1', '1', '1', '149225', 'اضافة فاتورة مبيعات', 'sellbillController.php', '39', '38', '9', '2024-12-12 20:39:11','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '25640',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('24740','900', '0', '1', 'اضافة فاتورة مبيعات', '149225', '25640', '2024-12-12 20:39:11', '9',  'sellbillController.php','1','','0');
UPDATE client SET  delegateid = 73 where clientid = 1;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 900, 765, 765
                    , 765, 765, 765, 765
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,765, 553, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+765
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+765, sellCostMeanBuyPrice = sellCostMeanBuyPrice+765
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+765, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+765
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+765
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+765
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+553
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
 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-12', 900, 765, 765
                    , 765, 765, 765, 765
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,765, 553, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+765
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+765, sellCostMeanBuyPrice = sellCostMeanBuyPrice+765
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+765, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+765
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+765
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+765
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+553
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , 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, 765, 765
                    , 765, 765, 765, 765, 765, 553)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+900, netSellCostBuyPrice = netSellCostBuyPrice+765
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+765
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+765
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+765
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+765
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+765
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+765
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+553;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b2d5ebd981 and sellbillId = 149225 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b31033e20e
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(637,@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-12 20:52:51', '0675b31033e20e', '637', '0.00', '-680', '15', '1', '695', '680', '0', '-680', '1', '2024-12-12 20:54:13', '', '9', '0', 'فؤاد ادوار V0001','1', '1', '5', '24', 'فؤاد ادوار V0001', '2', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0','0','0','-1','0','1','1','');
UPDATE client SET  clientdebt = '-680', userid = '9' WHERE clientid = '637';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('637','0.00','680','1','اضافة فاتورة مردوات مبيعات','16746', '-680', '2024-12-12 20:54:13', '9', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '680', '0', null, '0', null, null,'', '0','1','1','680','1','2024-12-12 20:52:51','0','0');
UPDATE client SET  inUse = 0 where clientid = 637;
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 ('380.00', 'R3328', '16746', '1', '16325', '1', '450', '450', '0', '', '1', '0', '16325', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','450','450','0','','0');
UPDATE returnsellbilldetail 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 returnsellbilldetailid = 21906;
 INSERT INTO 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 459.71223021583, 380, 380, 380
                    , 380, 380, 380, 0, 1, 0, 0, 380, 380)
                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+459.71223021583, returnSellCostBuyPrice = returnSellCostBuyPrice+380, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+380
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+380, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+380
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+380
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+380
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+380
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+380
                        , 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 459.71223021583, 380, 380, 380
                    , 380, 380, 380, 0, 0, 380, 380)
                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+459.71223021583, returnSellCostBuyPrice = returnSellCostBuyPrice+380, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+380
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+380, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+380
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+380
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+380
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+380
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+380;
UPDATE storedetail SET  productquantity = '41', userid = '9', storedetaildate = '2024-12-12 20:54:13' WHERE storedetailid = '16324';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16325', '1', '1', '0', '16746', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '40', '41', '9', '2024-12-12 20:54:13','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro,proHeight,proWidth,soldSerialsInDetails,lastbuyprice_withTax,meanbuyprice_withTax,returnsellbilldetailpriceC,returnsellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,lastbuyprice_withDiscountAndTax) VALUES ('250.00', '06584', '16746', '5', '14997', '1', '245', '245', '0', '', '1', '0', '14997', '0.00', '-1','1','0','','','0','0','0','0','0','1','1','1','','0','0','245','245','0','','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
        
                where returnsellbilldetailid = 21907;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (14997, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250.28776978417, 250, 250, 250
                    , 250, 250, 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+250.28776978417, returnSellCostBuyPrice = returnSellCostBuyPrice+250, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+250
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+250, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+250
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+250
                            , 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-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 250.28776978417, 250, 250, 250
                    , 250, 250, 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+250.28776978417, returnSellCostBuyPrice = returnSellCostBuyPrice+250, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+250
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+250, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+250
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+250
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+250
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '2', userid = '9', storedetaildate = '2024-12-12 20:54:13' WHERE storedetailid = '14996';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('14997', '1', '1', '0', '16746', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '1', '2', '9', '2024-12-12 20:54:13','0','0');
UPDATE client SET  delegateid = 24 where clientid = 637;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 680, 630, 630, 630
                    , 630, 630, 630 ,0, 0, 380, 380)
                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+680, returnSellCostBuyPrice = returnSellCostBuyPrice+630, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+630
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+630, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+630
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+630
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+630
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+380
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+380;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (637, '2024-12-12', 0, 0, 0
                    , 0, 0, 0, 0
                    , 680, 630, 630, 630
                    , 630, 630, 630 ,0, 0, 380, 380)
                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+680, returnSellCostBuyPrice = returnSellCostBuyPrice+630, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+630
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+630, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+630
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+630
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+630
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+380
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+380;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, -680, -630, -630
                    , -630, -630, -630, -630, -380, -380)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-680, netSellCostBuyPrice = netSellCostBuyPrice+-630
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-630
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-630
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-630
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-630
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+-630
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+-380
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+-380;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b31033e20e and sellbillId = 16746 and returnsellbillId = 16746
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b2dcfefa6a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(637,@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-12 20:39:11', '0675b2dcfefa6a', '637', '-680.00', '1300', '60', '1', '2040.00', '1980', '0', '1980', '1', '2024-12-12 20:54:31', '', '9', '0', 'فؤاد ادوار V0001', '1', '1', '3', '24', 'فؤاد ادوار V0001', '4' ,'0','','','','','-1','0','0','0','0','0','1980','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1300', userid = '9' WHERE clientid = '637';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('637','-680.00','1980','0','اضافة فاتورة مبيعات','149226', '1300', '2024-12-12 20:54:31', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1980', '0', null, '0', null, null,'', '0','1','1','1980','1','2024-12-12 20:39:11','0','0');
UPDATE client SET  inUse = 0 where clientid = 637;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 35567;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149226', '5', '15673', '2', '360', '720', '0', '', '1', '2024-12-12 20:54:31', '15673', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35567-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 = 545267;
 INSERT INTO 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-12', 698.82352941176, 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+698.82352941176, 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-12', 698.82352941176, 590, 590
                    , 590, 590, 590, 590
                    , 0, 0, 0, 0
                    , 0, 0, 0, 590, 590, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+698.82352941176, 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 = '36', userid = '9', storedetaildate = '2024-12-12 20:54:31' WHERE storedetailid = '15672';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('15673', '1', '2', '1', '149226', 'اضافة فاتورة مبيعات', 'sellbillController.php', '38', '36', '9', '2024-12-12 20:54:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35344;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('620','16014', '149226', '14', '16014', '1', '720', '720', '0', '', '1', '2024-12-12 20:54:31', '16014', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35344-1,','1','1','0','0','720','720','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 620.00 , meanbuyprice = 620.00, lastbuyprice_withDiscount = 620.00, meanbuyprice_withDiscount = 620.00
        , lastbuyprice_withTax = 620, meanbuyprice_withTax = 620, lastbuyprice_withDiscountAndTax = 620
                where sellbilldetailid = 545268;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16014, '2024-12-12', 698.82352941176, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 620, 620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+698.82352941176, 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+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 698.82352941176, 620, 620
                    , 620, 620, 620, 620
                    , 0, 0, 0, 0
                    , 0, 0, 0, 620, 620, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+698.82352941176, 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 = '4', userid = '9', storedetaildate = '2024-12-12 20:54:31' WHERE storedetailid = '16013';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16014', '1', '1', '1', '149226', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5', '4', '9', '2024-12-12 20:54:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 36027;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity,proHeight,proWidth,lastbuyprice_withTax,meanbuyprice_withTax,sellbilldetailpriceC,sellbilldetailtotalpriceC,discountvalueC,proSellTrackingSerial,travelBrokerId,categorydiscount,lastbuyprice_withDiscountAndTax,prosellDiscountPer,prosellDiscountPerType,prosellDiscountVal) VALUES ('435','H1621', '149226', '14', '16255', '1', '600', '600', '0', '', '1', '2024-12-12 20:54:31', '16255', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','36027-1,','1','1','0','0','600','600','0','','0','0.00','0','0','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 435.00 , meanbuyprice = 414.00, lastbuyprice_withDiscount = 435.00, meanbuyprice_withDiscount = 414.00
        , lastbuyprice_withTax = 435, meanbuyprice_withTax = 480, lastbuyprice_withDiscountAndTax = 435
                where sellbilldetailid = 545269;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (16255, '2024-12-12', 582.35294117647, 435, 435
                    , 414, 435, 414, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0, 435, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+582.35294117647, sellCostBuyPrice =sellCostBuyPrice+435
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+435, sellCostMeanBuyPrice = sellCostMeanBuyPrice+414
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+435, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+414
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (1, '2024-12-12', 582.35294117647, 435, 435
                    , 414, 435, 414, 440
                    , 0, 0, 0, 0
                    , 0, 0, 0, 435, 480, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+582.35294117647, sellCostBuyPrice =sellCostBuyPrice+435
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+435, sellCostMeanBuyPrice = sellCostMeanBuyPrice+414
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+435, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+414
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+440
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+435
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+480
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+0
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+0;
UPDATE storedetail SET  productquantity = '19', userid = '9', storedetaildate = '2024-12-12 20:54:31' WHERE storedetailid = '16254';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16255', '1', '1', '1', '149226', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20', '19', '9', '2024-12-12 20:54:31','0','0');
UPDATE client SET  delegateid = 24 where clientid = 637;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 1980, 1645, 1645
                    , 1624, 1645, 1624, 1650
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1645, 1690, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1980, sellCostBuyPrice =sellCostBuyPrice+1645
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1645, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1624
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1645, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1624
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1645
                            , 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES (637, '2024-12-12', 1980, 1645, 1645
                    , 1624, 1645, 1624, 1650
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,1645, 1690, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1980, sellCostBuyPrice =sellCostBuyPrice+1645
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1645, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1624
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1645, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1624
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+1650
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+1645
                            , 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 1980, 1645, 1645
                    , 1624, 1645, 1624, 1650, 1645, 1690)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1980, netSellCostBuyPrice = netSellCostBuyPrice+1645
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1645
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1624
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1645
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1624
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+1650
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+1645
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+1690;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b2dcfefa6a and sellbillId = 149226 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

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

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =245964
-- ----------------------------------------------------------------------------------------------------

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

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:25:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:55:14", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 20:55:14', '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-12 17:25:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:55:15", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientPayedDeptController.php', '2024-12-12 20:55:15', '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-12 17:25:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:55:25", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:55:25', '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-12 17:25:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 20:55:52", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 20:55:52', '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-12 17:26:42";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:56:42", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 20:56:42', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:27:04";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:57:04", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 20:57:04', '2', 'add', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/clientDeficitController.php?do=add');

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add - with clientid =133
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(133,@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 ('133','-845.00','845','0','تسوية عجز عميل بالزيادة','-1', '0', '2024-12-12 20:57:04', '2', 'clientDeficitController.php', '', '845', '0', null, '0', null, null,'', '0','1','1','845','1','','0','0');
UPDATE client SET  clientdebt = '0' , clientdate = '2024-12-12', userid = '2' WHERE clientid = '133';
UPDATE client SET  inUse = 0 where clientid = 133;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientDeficitController add end- with clientid =133 ,id=245965
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:27:05";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:57:05", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 20:57:05', '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-12 17:27:06";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:57:06", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('clientDeficitController.php', '2024-12-12 20:57:06', '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-12 17:27:15";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:57:15", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 20:57:15', '2', '', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:27:27";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:57:27", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 20:57:27', '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', 'باقي حساب عميل', '', '1895', '2024-12-12', '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 = '517033.5',  userid = '2' WHERE saveid = '2';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('518928.50','1895', '1', '2', 'إضافة مصروف', '25629', '517033.5', '2024-12-12 20:57:27', '2',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'باقي حساب عميل', expensesdetails = '', expensesValue = '1895.00', expensesdate = '2024-12-12', 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 = '25629';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:27:27";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:57:27", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 20:57:27', '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-12 17:27:29";
UPDATE user SET loginip = "192.168.1.60", lastactivetime = "2024-12-12 20:57:29", deviceType = "DESKTOP" WHERE userid = 2;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 20:57:29', '2', 'show', '192.168.1.60', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php?do=show');
UPDATE user SET loginip = "" WHERE userid = 2;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:37:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:07:54", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 21:07:54', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:38:57";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:08:57", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:08:57', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:39:04";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:09:04", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:09:04', '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-12', '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 = '26890',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26940.00','50', '1', '1', 'إضافة مصروف', '25630', '26890', '2024-12-12 21:09:04', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'محمد عبدة', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25630';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:39:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:09:05", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:09: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-12 17:39:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:09:06", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:09:06', '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-12 17:39:10";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:09:10", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:09:10', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:39:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:09:42", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:09:42', '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', 'لاحا', '', '150', '2024-12-12', '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 = '26740',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26890.00','150', '1', '1', 'إضافة مصروف', '25631', '26740', '2024-12-12 21:09:42', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'لاحا', expensesdetails = '', expensesValue = '150.00', expensesdate = '2024-12-12', 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 = '25631';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:39:43";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:09:43", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:09:43', '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-12 17:39:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:09:45", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:09:45', '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-12 17:50:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:20:38", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 21:20:38', '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-12 17:51:08";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:21:08", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 21:21:08', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b378640501
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(637,@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-12 21:20:38', '0675b378640501', '637', '0.00', '285', '15', '1', '300.00', '285', '0', '285', '1', '2024-12-12 21:21:09', '', '9', '0', 'فؤاد ادوار V0001', '1', '1', '3', '24', 'فؤاد ادوار V0001', '1' ,'0','','','','','-1','0','0','0','0','0','285','0','','0','0','0','0','0','0','0','0','0','0','0','','','','0','','0','','0','-1','2024-12-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '285', userid = '9' WHERE clientid = '637';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('637','0.00','285','0','اضافة فاتورة مبيعات','149227', '285', '2024-12-12 21:21:09', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '285', '0', null, '0', null, null,'', '0','1','1','285','1','2024-12-12 21:20:38','0','0');
UPDATE client SET  inUse = 0 where clientid = 637;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 35823;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,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', '149227', '5', '16239', '1', '300', '300', '0', '', '1', '2024-12-12 21:21:09', '16239', '0.00', '-1', '1','0','','','0','0','0','0','0','0','1','0','','35823-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 = 545270;
 INSERT INTO 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-12', 285, 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+285, 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-12', 285, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0, 240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+285, 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 = '25', userid = '9', storedetaildate = '2024-12-12 21:21:09' WHERE storedetailid = '16238';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16239', '1', '1', '1', '149227', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26', '25', '9', '2024-12-12 21:21:09','0','0');
UPDATE client SET  delegateid = 24 where clientid = 637;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('2024-12-12', 285, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+285, 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 (637, '2024-12-12', 285, 240, 240
                    , 240, 240, 240, 240
                    , 0, 0, 0, 0
                    , 0, 0, 0 ,240, 240, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+285, 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, 285, 240, 240
                    , 240, 240, 240, 240, 240, 240)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+285, 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 0675b378640501 and sellbillId = 149227 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:51:09";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:21:09", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 21:21:09', '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-12 17:53:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:23:46", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:23:46', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:53:53";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:23:53", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:23:53', '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', 'كريم', '', '60', '2024-12-12', '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 = '26680',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26740.00','60', '1', '1', 'إضافة مصروف', '25632', '26680', '2024-12-12 21:23:53', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كريم', expensesdetails = '', expensesValue = '60.00', expensesdate = '2024-12-12', 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 = '25632';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:53:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:23:54", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:23:54', '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-12 17:53:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:23:55", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:23:55', '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-12 17:54:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:24:14", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:24:14', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:54:19";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:24:19", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:24:19', '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', 'كريم', '', '10', '2024-12-12', '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 = '26670',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26680.00','10', '1', '1', 'إضافة مصروف', '25633', '26670', '2024-12-12 21:24:19', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كريم', expensesdetails = '', expensesValue = '10.00', expensesdate = '2024-12-12', 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 = '25633';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 17:54:20";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:24:20", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:24:20', '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-12 17:54:22";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:24:22", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 21:24:22', '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-12 17:59:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:29:34", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 21:29:34', '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-12 18:21:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:51:51", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 21:51:51', '9', 'addAndRetuen', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/sellbillController.php?do=addAndRetuen');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0675b399e6d135
-- ----------------------------------------------------------------------------------------------------

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-12 21:29:34', '0675b399e6d135', '1', '0.00', '0', '0', '1', '450.00', '450', '450', '0', '1', '2024-12-12 21:51:51', '', '9', '0', 'نقدي', '1', '0', '3', '5', 'نقدي', '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-12','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '9' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor,userSelectedDate,paySerialNo,totalpayments ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','149228', '0', '2024-12-12 21:51:51', '9', 'sellbillController.php', 'اضافة فاتورة مبيعات', '450', '0', null, '0', null, null,'', '0','1','1','0','1','2024-12-12 21:29:34','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', '149228', '14', '16406', '1', '450', '450', '0', '', '1', '2024-12-12 21:51:51', '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 = 545271;
 INSERT INTO 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-12', 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-12', 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 = '14', userid = '9', storedetaildate = '2024-12-12 21:51:51' WHERE storedetailid = '16405';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('16406', '1', '1', '1', '149228', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15', '14', '9', '2024-12-12 21:51:51','0','0');
CALL saveInUse(1,@saveidis,@savecurrentvalueis,@currencyIdis,@treeIdis,@conversionFactoris);
UPDATE save SET  savecurrentvalue = '27120',  userid = '9' WHERE saveid = '1';
UPDATE save SET  inUse = 0 where saveid = 1;
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26670','450', '0', '1', 'اضافة فاتورة مبيعات', '149228', '27120', '2024-12-12 21:51:51', '9',  '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-12', 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;
 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-12', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice,netSellCostLastBuyPricewithTax,netSellCostMeanBuyPricewithTax)
                    VALUES (1, 450, 365, 365
                    , 365, 365, 365, 365, 365, 365)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+450, netSellCostBuyPrice = netSellCostBuyPrice+365
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+365
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+365
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+365
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+365
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+365
                , netSellCostLastBuyPricewithTax = netSellCostLastBuyPricewithTax+365
                , netSellCostMeanBuyPricewithTax = netSellCostMeanBuyPricewithTax+365;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0675b399e6d135 and sellbillId = 149228 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:21:52";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 21:51:52", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 21:51:52', '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-12 18:39:51";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:09:51", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:09: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-12 18:46:34";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:16:34", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:16:34', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:46:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:16:46", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:16:46', '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-12', '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 = '27070',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('27120.00','50', '1', '1', 'إضافة مصروف', '25634', '27070', '2024-12-12 22:16:46', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'عبدة احمد', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25634';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:46:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:16:46", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:16:46', '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-12 18:46:48";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:16:48", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:16:48', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:46:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:16:56", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:16:56', '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', 'يوسف لاحا', '', '150', '2024-12-12', '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 = '26920',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('27070.00','150', '1', '1', 'إضافة مصروف', '25635', '26920', '2024-12-12 22:16:56', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'يوسف لاحا', expensesdetails = '', expensesValue = '150.00', expensesdate = '2024-12-12', 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 = '25635';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:46:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:16:56", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:16:56', '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-12 18:46:58";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:16:58", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:16:58', '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-12 18:47:07";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:17:07", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:17:07', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:47:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:17:13", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:17:13', '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', 'كريم', '', '10', '2024-12-12', '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 = '26910',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26920.00','10', '1', '1', 'إضافة مصروف', '25636', '26910', '2024-12-12 22:17:13', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كريم', expensesdetails = '', expensesValue = '10.00', expensesdate = '2024-12-12', 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 = '25636';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:47:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:17:13", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:17:13', '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-12 18:47:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:17:15", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:17:15', '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-12 18:47:15";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:17:15", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:17: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-12 18:48:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:18:13", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 22:18:13', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:48:24";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:18:24", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:18:24', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:48:29";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:18:29", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:18:29', '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-12', '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 = '26860',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26910.00','50', '1', '1', 'إضافة مصروف', '25637', '26860', '2024-12-12 22:18:29', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'مشال', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25637';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:48:30";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:18:30", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:18:30', '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-12 18:48:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:18:31", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:18:31', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:48:37";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:18:37", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:18:37', '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-12', '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 = '26830',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26860.00','30', '1', '1', 'إضافة مصروف', '25638', '26830', '2024-12-12 22:18:37', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كرت شحن', expensesdetails = '', expensesValue = '30.00', expensesdate = '2024-12-12', 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 = '25638';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:48:38";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:18:38", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:18: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-12 18:48:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:18:40", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:18:40', '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-12 18:48:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:18:40", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:18:40', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:49:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:19:01", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:19:01', '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-12', '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 = '26780',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26830.00','50', '1', '1', 'إضافة مصروف', '25639', '26780', '2024-12-12 22:19:01', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'محمد صلاح', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-12-12', 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 = '25639';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 18:49:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:19:02", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:19:02', '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-12 18:49:03";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:19:03", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 22:19: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-12 19:23:17";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:53:17", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 22:53:17', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:23:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:53:47", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:53:47', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:23:54";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:53:54", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:53:54', '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-12', '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 = '26580',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26780.00','200', '1', '1', 'إضافة مصروف', '25640', '26580', '2024-12-12 22:53:54', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'النون', expensesdetails = '', expensesValue = '200.00', expensesdate = '2024-12-12', 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 = '25640';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:23:55";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:53:55", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:53:55', '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-12 19:23:56";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:53:56", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 22:53:56', '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-12 19:23:58";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:53:58", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 22:53:58', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:24:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 22:54:02", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 22:54:02', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:34:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:04:42", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:04:42', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:35:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:05:01", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:05:01', '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', 'كريم هادي', '', '350', '2024-12-12', '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 = '26230',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26580.00','350', '1', '1', 'إضافة مصروف', '25641', '26230', '2024-12-12 23:05:02', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'كريم هادي', expensesdetails = '', expensesValue = '350.00', expensesdate = '2024-12-12', 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 = '25641';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:35:02";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:05:02", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:05:02', '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-12 19:35:04";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:05:04", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:05:04', '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-12 19:35:06";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:05:06", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:05:06', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:35:12";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:05:12", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:05:12', '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-12', '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 = '26030',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26230.00','200', '1', '1', 'إضافة مصروف', '25642', '26030', '2024-12-12 23:05:12', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'خشبه', expensesdetails = '', expensesValue = '200.00', expensesdate = '2024-12-12', 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 = '25642';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:35:13";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:05:13", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:05:13', '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-12 19:35:14";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:05:14", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:05:14', '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-12 19:35:41";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:05:41", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('savedailyController.php', '2024-12-12 23:05:41', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/savedailyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:38:25";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:08:25", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:08: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-12 19:38:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:08:31", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:08:31', '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-12', '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 = '25930',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('26030.00','100', '1', '1', 'إضافة مصروف', '25643', '25930', '2024-12-12 23:08:31', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'خشبه', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-12', 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 = '25643';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:38:31";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:08:31", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:08:31', '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-12 19:38:33";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:08:33", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:08:33', '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-12 19:46:40";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:16:40", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:16:40', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:46:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:16:47", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:16:47', '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-12', '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 = '25830',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('25930.00','100', '1', '1', 'إضافة مصروف', '25644', '25830', '2024-12-12 23:16:47', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'بيدق', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-12', 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 = '25644';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:46:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:16:47", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:16:47', '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-12 19:46:49";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:16:49", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:16:49', '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-12 19:46:53";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:16:53", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:16: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-12 19:47:03";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:17:03", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:17:03', '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-12', '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 = '25800',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('25830.00','30', '1', '1', 'إضافة مصروف', '25645', '25800', '2024-12-12 23:17:03', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'نافحة ', expensesdetails = '', expensesValue = '30.00', expensesdate = '2024-12-12', 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 = '25645';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:47:04";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:17:04", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:17:04', '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-12 19:47:05";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:17:05", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 23:17:05', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:47:37";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:17:37", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:17:37', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/expensesController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:47:59";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:17:59", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:17:59', '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-12', '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 = '25700',  userid = '9' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('25800.00','100', '1', '1', 'إضافة مصروف', '25646', '25700', '2024-12-12 23:17:59', '9',  'expensesController.php','0','','0');
UPDATE expenses SET expensestypeid = '1', expensesname = 'ابراهيم الصغير', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-12-12', 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 = '25646';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:48:00";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:18:00", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:18:00', '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-12 19:48:01";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:18:01", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('expensesController.php', '2024-12-12 23:18:01', '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-12 19:48:03";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:18:04", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 23:18:04', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:49:45";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:19:45", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 23:19:45', '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', '25700', '2024-12-12', '9', '0', '0','','1','1','0','0','25700');
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 ('25700.00','25700', '1', '1', 'تحويل امول الى الخزنة  [ خزنة البيت ] ', '3492', '0', '2024-12-12 23:19:45', '9',  'transfermoneyController.php','0','','0');
UPDATE save SET  savecurrentvalue = '216760',  userid = '9' WHERE saveid = '4';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note,clientdebtchangeidfk) VALUES ('191060.00','25700', '0', '4', 'تحويل امول من الخزنة  [ نقدي ] ', '3492', '216760', '2024-12-12 23:19:45', '9',  'transfermoneyController.php','0','','0');
UPDATE transfermoney SET saveidfrom = '1', saveidto = '4', transfermoneyvalue = '25700.00', transfermoneydate = '2024-12-12', userid = '9', conditions = '0' , dailyentryid = '0' , comment = '',currencyId='1',conversionFactor='1',conversionFactorFrom='1',conversionFactorTo='1',transfermoneyvalueInCurrency='25700' WHERE transfermoneyid = '3492';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:49:46";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:19:46", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 23:19:46', '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-12 19:49:47";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:19:47", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 23:19:47', '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-12 19:50:03";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:20:03", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 23:20: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-12 19:50:16";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:20:16", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 23:20:16', '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-12 19:50:18";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:20:18", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('transfermoneyController.php', '2024-12-12 23:20:18', '9', '', '192.168.1.13', '', 'DESKTOP','https://41.131.49.210/~newweb/erp/controllers/transfermoneyController.php');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-12-12 19:50:42";
UPDATE user SET loginip = "192.168.1.13", lastactivetime = "2024-12-12 23:20:42", deviceType = "DESKTOP" WHERE userid = 9;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType,completeURL) VALUES ('sellbillController.php', '2024-12-12 23:20:42', '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 userid = 1;
